0
I am trying to use jspdf based on the examples I have seen here. And I am having 2 basic problems if I use the code below:
$('#download_pdf').click(function() {
var doc = new jsPDF('portrait', 'pt', 'a4'),
data = new Date();
margins = {
top: 40,
bottom: 60,
left: 40,
width: 1000
};
doc.fromHTML($('#printavel'),
margins.left, // x coord
margins.top, { pagesplit: true },
function(dispose){
doc.save("Recibo - "+data.getDate()+"/"+data.getMonth()+"/"+data.getFullYear()+".pdf");
});
});
}
It cannot receive the contents of the div "#printavel" and the pdf is generated like this:
If I use the code below:
$('#download_pdf').click(function() {
var doc = new jsPDF('landscape', 'pt', 'a4');
doc.addHTML($('#printavel'), function() {
doc.save("ReciboDoacao.pdf");
});
});
The pdf is generated this way:
I hate that.. :(
download_pdf: It is the button that triggers the pdf generation.
printavel: It is the div where ta text that goes pro pdf.
Questions:
First up, why can’t I get the contents of the div through? 2º In the second example, why are the rays generating the pdf looking like a DOS screen?
Any help is welcome..
If someone can show me how to pass the content of the div according to the first example, or how to generate the pdf without being that DOS screen of the second example, any of the case already serves. The pdf doesn’t have to have anything else, it’s a simple text with white background and black Arial font, nothing more.
I put a video showing the error: http://softarena.ml/erro.mp4. No problem to display the card number pq is just a test card
– Linces Marques