Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I´m here with the following problem:
When using jsPDF it should be possible to generate a PDF from HTML code.
The way im looking at doing this is with the use of images, I can't seem to get html tables into the pdf the right way (this clears all of the table layouts). While using html2canvas, addHTML plugins the pdf still won't be generated with content. I'm not getting any errors, so I don't know what the problem could be.
Also with the examples given at the link below, the code is written a bit differently, but when I use this code the anomymous function which is passed on as a parameter isn't even executed, therefor i use to following construct.
`pdf.addHTML(document.title, (function() {})());`
Even when this is right, the content won't be shown inside of the PDF.

http://mrrio.github.io/jsPDF/#

My code has the following structure(s) which I has tried:

JavaScript
$(function() {
    $('#createPDF').click(function () {

        var pdf = new jsPDF('p', 'pt', 'a4');
        var options = {
                 pagesplit: true
            };
        pdf.addHTML($('body'), 0, 0, options, (function() {
            pdf.save("test.pdf");
        })());





        var pdf = new jsPDF('p','pt','a4');
        pdf.addHTML('Hallo' ,function() {
            var string = pdf.output('datauristring');
            $('.preview-pane').attr('src', string);
        });
        pdf.save('Test.pdf');




        var doc = new jsPDF();
        window.alert(document.title);
        doc.addHTML(document.title, (function() {})());
        doc.text(20, 20, document.getElementById('learningCurve'));
        doc.text(20, 20, document.getElementById('123'));
        doc.setProperties({ pagesplit: true} );
        doc.addPage();
        doc.text('Do you like that?');
        doc.save('Maandrapportage.pdf');
    });
});
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900