I am trying to generate a PDF with js
using html2canvas
and jsPDF
. When content is being viewed, everything works 100%, but I need that content to be hidden. Already tried:
- display: none;
- visibility: hidden;
- Position: absolute;
Among other things. I always get this error when I try to generate pdf with "hidden" content on the page.
jspdf.debug.js: 2571 Uncaught Error: Supplied data is not a JPEG
Here is the code used:
<div id="conteudo-pdf">
Conteúdo
</div>
<script type="text/javascript">
var doc = new jsPDF();
$('#btGerarPDF').click(function () {
doc.addHTML($("#conteudo-pdf"), function(){
doc.save('arquivo.pdf');
});
});
</script>