html2canvas

Using html2canvas to render a highcharts chart to pdf doesn't work on IE and Firefox

爷,独闯天下 提交于 2019-12-04 03:53:48
We are using html2canvas.js and html2canvas.svg.js (version 0.5.0 beta1) and highcharts.js to download a donut chart into pdf. This works as expected in Chrome, however in IE and Firefox this isnt working. In IE the chart is rendered incorrectly, and in Firefox it is not rendered at all. Below are screenshots of the download in Chrome, IE and Firefox Chrome IE (Edge) Firefox The code i am using to do the html2canvas is as follows: html2canvas($("#container"), { onrendered: function (canvas) { var imgData = canvas.toDataURL( 'image/png'); var doc = new jsPDF('p', 'mm'); doc.addImage(imgData,

html2canvas and jsPDF : send generated pdf as email attachment

落爺英雄遲暮 提交于 2019-12-04 03:43:42
问题 I have created a function to take screenshot of current webpage and save it as PDF using html2canvas and jsPDF. Following is my code for it: <script> function downloadpdf(){ html2canvas(document.body, { onrendered: function(canvas){ var imgData = canvas.toDataURL("image/jpeg"); var a = document.createElement('a'); var doc = new jsPDF('p','mm'); doc.addImage(imgData, 'JPEG', 15, 40, 180, 160); doc.save($.now()+'.pdf'); } }); } </script> By using the above code, I am able to download the file

vue项目vue页面内容生成图片并保存本地方案

一曲冷凌霜 提交于 2019-12-04 02:15:25
使用 html2canvas 插件 1、安装: npm install --save html2canvas 2、在需要使用的vue组件中引入: import html2canvas from "html2canvas" 3、将制定区域内转成图片   添加ref标记 <div class="container" ref="imageDom"></div> /** * 将页面指定节点内容转为图片 * 1.拿到想要转换为图片的内容节点DOM; * 2.转换,拿到转换后的canvas * 3.转换为图片 */ clickGeneratePicture() { //生成图片 html2canvas(this.$refs.imageDom).then(canvas => { // 转成图片,生成图片地址 this.imgUrl = canvas.toDataURL("image/png"); //可将 canvas 转为 base64 格式 }); } 4、创建隐藏的可下载链接 --- 必须同源(访问的网站域名与服务器域名一致)才能下载 var eleLink = document.createElement("a"); eleLink.href = this.imgUrl; // 转换后的图片地址 eleLink.download = "历史曲线图"; document.body

html2canvas not working at all

非 Y 不嫁゛ 提交于 2019-12-03 21:47:41
Here is the code which isn't working. Basically I'm allowing the user to edit some text in the div and then display its screenshot. Can someone please tell why is it not working? <!doctype html> <html> <head> <link type="text/css" rel="stylesheet" href="main.css" /> <title>Poster</title> </head> <body> <div id="main_image"> <img src="image.jpg" id= "image"/> <div id="user_text">IT IS TOTALLY AWESOME</div> </div> <div id="edit_text_box"> <textarea id="user_input" placeholder="Your text here.." rows="2" cols="30" ></textarea> <div id="change_size"> <span style="float: left;">FONT-SIZE : </span>

Looping html2canvas

若如初见. 提交于 2019-12-03 17:01:43
I'm having a bit of trouble trying to implement the html2canvas script in a for loop. I'm writing a Javascript function that uses an array of data to modify the style of a group of elements, captures the container div as a canvas, converts it into an image, appends it to the document body and then moves on to the next index of the array. The part where I'm having trouble is at the very end of my loop: html2canvas(document.getElementById("background"), { onrendered: function(canvas) { var imgdata = canvas.toDataURL("image/png"); var obj = document.createElement("img"); obj.src=imgdata; document

JSPDF - addHTML() Multiple Canvas Page

南笙酒味 提交于 2019-12-03 16:58:34
问题 I noticed already have a release "addHTML() can now split the canvas into multiple pages" which can find through this link : https://github.com/MrRio/jsPDF/releases/tag/v1.0.138. May i know how it work? In my case, i just tried it out when click on "save as pdf" button, it just render a single page instead of multiple pages (sometimes didn't worked, i assume because the content is too long to be generated as pdf). Would appreciate if there are some examples for this case. Thanks! Attached my

html2canvas in angular 4

醉酒当歌 提交于 2019-12-03 13:27:50
问题 I am able to take a screenshot using html2canvas in angular 4 but i need to send the string image to the server side using a http post call Component import { Component, OnInit, NgZone } from '@angular/core'; import { Router, ActivatedRoute, Params } from '@angular/router'; import { EventsEmitter } from '../../assets/scripts/services/eventsEmitter'; import { WindowRef } from '../../assets/scripts/services/window'; import { ImagesService } from '../images/images.component.service'; import {

html2canvas javascript screenshot and upload

↘锁芯ラ 提交于 2019-12-03 13:27:06
问题 Would it be possible to use html2canvas (This) to take a picture of the user`s screen but also upload the image, get the upload link and send it with ajax to the webserver? if so, how can i do this? 回答1: Yes it is certainly possible to do such a thing. Firstly use the html2canvas api to take a picture of the user's screen: html2canvas(document.body).then(function(canvas) { }); Secondly use the following function to convert the returned canvas image into a base64 encoded URL (defaults to png):

Download html2canvas image to desktop

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I found this https://jsfiddle.net/8ypxW/3/ and I would like to know how to download image to desktop. I only see save png but no download if it's possible can you give me the script? $(function() { $("#btnSave").click(function() { html2canvas($("#widget"), { onrendered: function(canvas) { theCanvas = canvas; document.body.appendChild(canvas); // Convert and download as image Canvas2Image.saveAsPNG(canvas); $("#img-out").append(canvas); // Clean up //document.body.removeChild(canvas); } }); }); }); 回答1: The problem was the wrong url of

How to generate “screenshot” of html div with external images?

不打扰是莪最后的温柔 提交于 2019-12-03 09:40:41
问题 I have a HTML div with external images. (The following is an example, but in the actual case I am using Amazon S3, so downloading and storing the image on the same server is not an option) Currently I am using html2canvas to convert the div to image. However, the external image is always replaced by a blank space. The code I use to capture the image: $(function() { $("#btnSave").click(function() { html2canvas($("#widget"), { onrendered: function(canvas) { theCanvas = canvas; document.body