html2canvas

html2canvas - SecurityError: The operation is insecure

笑着哭i 提交于 2019-12-20 03:02:46
问题 I have used html2canvas.js in my project for convert my element(body) into canvas and then convert canvas to image. My element contains images that load from cross domain. Canvas create from element is working perfectly, but when try to canvas.toDataURL("image/png"); it gives error SecurityError: The operation is insecure Please help me to solve this issue. canvas.toDataURL("image/png"); is working fine when image not load from cross domain. Thanks in advance. 回答1: Not really an html2canvas

change transparent color into white in html2canvas

吃可爱长大的小学妹 提交于 2019-12-19 19:45:21
问题 I am using javascript library html2canvas to save the table of my project. It works fine but when I save the image it shows transparent background color for PNG and background color black for jpeg. Here is what I did: <script> window.onload = function(){ html2canvas(document.getElementById("tablePng"),{ onrendered: function(canvas){ var img = canvas.toDataURL('image/jpeg'); $('#saveTable').attr('href',img); } }); }; </script> Doing these above will save the images but the background colour

Chartjs + jsPDF = Blurry image

隐身守侯 提交于 2019-12-19 17:32:51
问题 I'm having some issues exporting my Charts to PDF. I have this div <div id="chart-area"> <button type="button" id="btnPrint_" onClick="Print1()">Print</button> <?php echo '<h2 id="title">'.$_SESSION['team_name'].'</h2>'; ?> <canvas id="myChart" width="800" height="400"></canvas> <div id="legend"></div> </div> and I'm creating my chart using ChartJS $( document ).ready(function(){ var helpers = Chart.helpers; var canvas = document.getElementById('myChart'); var data = { labels: unique_dates,

Chartjs + jsPDF = Blurry image

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 17:32:26
问题 I'm having some issues exporting my Charts to PDF. I have this div <div id="chart-area"> <button type="button" id="btnPrint_" onClick="Print1()">Print</button> <?php echo '<h2 id="title">'.$_SESSION['team_name'].'</h2>'; ?> <canvas id="myChart" width="800" height="400"></canvas> <div id="legend"></div> </div> and I'm creating my chart using ChartJS $( document ).ready(function(){ var helpers = Chart.helpers; var canvas = document.getElementById('myChart'); var data = { labels: unique_dates,

Create pdf from ReactJS

百般思念 提交于 2019-12-19 11:46:13
问题 I am trying to Save ReactJS output(includes visual reports etc..) as PDF file. I used html2canvas to take screenshot and then used jspdf for converting that to PDF. But the problem is when screen size is reduced(or in mobile view) even screenshots are of small size as it uses DOM styling. So PDF is not properly generated as it should be seen in Full View. 回答1: You can use dom-to-png plugin by npm to create your image first and then just put that image in your PDF File. like this export

Can html2canvas render svg in a page?

女生的网名这么多〃 提交于 2019-12-18 21:12:11
问题 I am using html2canvas to create a 'screenshot' of a HTML page that contains SVG. Everything looks good, except the element. I know that it should be possible to render SVG in Canvas; PhantomJS, fabric.js and CanVG do it. Is this something that html2canvas does not support? Or am I doing something wrong, and this should just work? If this has not been implemented, what is the best way to extend html2canvas (using canvg)? 回答1: Capturing SVG images works by transforming them into canvas, using

html2canvas save image doesn't work

一世执手 提交于 2019-12-18 11:41:10
问题 I'm rendering a screenshot with html2canvas 0.4.0 and want to save it as image on my webserver. To do so, I've written the following function: JavaScript function screenShot(id) { html2canvas(id, { proxy: "https://html2canvas.appspot.com/query", onrendered: function(canvas) { $('body').append(canvas); // This works perfect... var img = canvas.toDataURL("image/png"); var output = img.replace(/^data:image\/(png|jpg);base64,/, ""); var Parameters = "image=" + output + "&filedir=" + cur_path; $

How to display an image in two pages in PDF using jsPDF?

江枫思渺然 提交于 2019-12-18 11:12:15
问题 I have a html page. In which I have a button , whenerever I click this button it will convert the entire html page into data image using html2canvas and placed it into PDF using jsPDF library. The javascript which I am using is $("#printButton").click(function(){ html2canvas([document.getElementById('form1')], { onrendered: function (canvas) { var imageData = canvas.toDataURL('image/jpeg',1.0); var doc = new jsPDF('landscape'); doc.addImage(imageData,'JPEG',5,20,200,150); doc.save('Test.pdf')

jsPdf using html2canvas.js for export pdf from html is not working for large data

痞子三分冷 提交于 2019-12-18 09:24:04
问题 Hi I am using jsPdf for making pdf of html content, it is going fine for short content and creating pdf , but when I am trying to use it on large content with html2canvas.js (for rendering css), it is not creating pdf. Any suggestions or sample code for this would be helpful.Thank you. 回答1: It is possible to create pdf for large files. There are primarily two ways to do this : 1. html -> canvas -> image -> pdf (I assume you are trying this approach) 2. html -> pdf (does not work if html

Image in PDF cut off: How to make a canvas fit entirely in a PDF page?

旧城冷巷雨未停 提交于 2019-12-17 19:50:57
问题 When placing the canvas in the PDF using the jspdf library makes the image cut off. html2canvas(myContainer, {background: 'red'}).then (canvas) -> imgData = canvas.toDataURL('image/jpeg', 1.0) window.open(imgData) # this is just a test that opens the image in a new tab and it displays nicely, the entire image pdf = new jsPDF("l", "pt", "b1") # tried a variety of formats but no luck pdf.addImage(imgData, 'JPEG', 0, 0) pdf.save('file.pdf') # the generated pdf that contains the image gets