I am using canvas and jspdf to convert from html to pdf
<script type="text/javascript" src="html2canvas.js"></script>
<script type="text/javascript" src="jspdf.debug.js"></script>
<script type="text/javascript">
window.onload = function() {
html2canvas(document.body).then(function(canvas) {
document.getElementById("cisForm").appendChild(canvas);
document.body.appendChild(canvas);
//var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
context.fillStyle = '#fff';
//window.location = canvas.toDataURL("pdf");
var imgData = canvas.toDataURL('image/png');
var doc = new jsPDF();
doc.addImage(canvas.toDataURL("image/jpeg"),"jpeg",0,0)
window.location=doc.output("datauristring")
});
}
</script>
It gives the PDF but the background color is black.
How can I remove bg color from pdf?
在html2canvas选项中添加背景:“#fff”。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.