html2canvas

change transparent color into white in html2canvas

我只是一个虾纸丫 提交于 2019-12-01 17:55:08
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 will be black and when changing var img = canvas.toDataURL('image/png'); the background will be

Three.js Screenshot

痴心易碎 提交于 2019-12-01 17:30:50
I need to make screenshot of website. I tried using html2canvas and all and it's working. But problem is i'm using THREE.WebGLRenderer and THREE.CSS3DRenderer (for html in webgl)... So when I make screenshot it makes images only from WebGLRenderer. CSS3DRenderer is ignored and I don't know how to make screenshot image from both renderers. I'm using this solution: Take screenshot of <body> with html2canvas and store img as JS var you can use this code var Render=new THREE.WebGLRenderer({antialias: true, preserveDrawingBuffer: true}); and a function onclick print: $("#btn_print").click(function(

Three.js Screenshot

血红的双手。 提交于 2019-12-01 16:43:11
问题 I need to make screenshot of website. I tried using html2canvas and all and it's working. But problem is i'm using THREE.WebGLRenderer and THREE.CSS3DRenderer (for html in webgl)... So when I make screenshot it makes images only from WebGLRenderer. CSS3DRenderer is ignored and I don't know how to make screenshot image from both renderers. I'm using this solution: Take screenshot of <body> with html2canvas and store img as JS var 回答1: you can use this code var Render=new THREE.WebGLRenderer(

Screenshot of a div with html2canvas. Sent to php, saved: Corrupted image

霸气de小男生 提交于 2019-12-01 07:17:25
I generate the canvas and pass it to php so: $('body').on('click','#save_image',function(){ html2canvas($('.myImage'), { onrendered: function(canvas) { //$('.imageHolder').html(canvas); var dataURL = canvas.toDataURL("image/png"); // $('.imageHolder').append('<img src="'+dataURL+'" />'); $('.imageHolder').html('Generating..'); $.post('image.php',{image: dataURL},function(data){ $('.imageHolder').html(data); }); } }); }); image.php: <? $image = $_POST['image']; echo "<img src='$image' alt='image' />"; $decoded = str_replace('data:image/png;base64,','',$image); $name = time(); file_put_contents(

Using jspdf to save html page as pdf, saved pdf contains incomplete page content if browser is zoomed, Why?

主宰稳场 提交于 2019-12-01 07:17:15
I am using jspdf and html2canvas combination to save html page as pdf. A pdf copy of current page is saved the moment you click a button. The problem is, if you zoom in the page, and then click the button, the saved pdf contains incomplete portion of the current page. Most of the part not visible on page due to zooming, gets cut off in the saved pdf page. What is the solution? Below is the js code being invoked upon click of save button- var pdf = new jsPDF('l', 'pt', 'a4'); var source = $('#someId')[0]; var options = { background : '#eee' }; pdf.addHTML(source, options, function(){ pdf.save(

html2canvas saving as a jpeg without opening in browser

自作多情 提交于 2019-12-01 06:36:36
I am trying to create a screengrab button that creates an image of the user's document.body . Ideally the user would then have an option to save the image locally as a .jpeg . I am getting close to creating the functionality I need using the html2canvas library. function screenGrabber() { html2canvas([document.body], { logging: true, useCORS: true, onrendered: function (canvas) { img = canvas.toDataURL("image/jpg"); console.log(img.length); console.log(img); window.location.href=img; // it will save locally } }); } To verify that this is working I've been opening the img variable in a new

Html2Canvas Resize

安稳与你 提交于 2019-12-01 05:18:40
I am using html2canvas in an effort to get a screenshot of a webpage and render it as a thumbnail (well, 400x300, not exactly a thumbnail). Based on the Screenshot console code , everything works great with the exception of the thumbnail part. How can I set the image size to 400x300? In firebug I locate the attribute as: <canvas style="width: 973px; height: 2184px;" width="973" height="2184"></canvas> . However, I cannot figure out in my code(below) or in the html2canvas.js where to hardcode the 400x300 parameters. screenshot.html: <html> <head> <title>Screenshot</title> <!--[if lt IE 9]>

Using jspdf to save html page as pdf, saved pdf contains incomplete page content if browser is zoomed, Why?

无人久伴 提交于 2019-12-01 05:08:34
问题 I am using jspdf and html2canvas combination to save html page as pdf. A pdf copy of current page is saved the moment you click a button. The problem is, if you zoom in the page, and then click the button, the saved pdf contains incomplete portion of the current page. Most of the part not visible on page due to zooming, gets cut off in the saved pdf page. What is the solution? Below is the js code being invoked upon click of save button- var pdf = new jsPDF('l', 'pt', 'a4'); var source = $('

html2canvas saving as a jpeg without opening in browser

北城以北 提交于 2019-12-01 04:38:45
问题 I am trying to create a screengrab button that creates an image of the user's document.body . Ideally the user would then have an option to save the image locally as a .jpeg . I am getting close to creating the functionality I need using the html2canvas library. function screenGrabber() { html2canvas([document.body], { logging: true, useCORS: true, onrendered: function (canvas) { img = canvas.toDataURL("image/jpg"); console.log(img.length); console.log(img); window.location.href=img; // it

Screenshot of a div with html2canvas. Sent to php, saved: Corrupted image

人走茶凉 提交于 2019-12-01 04:26:02
问题 I generate the canvas and pass it to php so: $('body').on('click','#save_image',function(){ html2canvas($('.myImage'), { onrendered: function(canvas) { //$('.imageHolder').html(canvas); var dataURL = canvas.toDataURL("image/png"); // $('.imageHolder').append('<img src="'+dataURL+'" />'); $('.imageHolder').html('Generating..'); $.post('image.php',{image: dataURL},function(data){ $('.imageHolder').html(data); }); } }); }); image.php: <? $image = $_POST['image']; echo "<img src='$image' alt=