Jspdf: Use jsPDF where the width and height is dynamic?

Created on 24 Feb 2016  路  1Comment  路  Source: MrRio/jsPDF

How can i use jsPDF where the width and height is dynamic? When the document height/width is large, i cannot seem to adjust the settings.

$(document).on("click", ".download-pdf", function() {
    html2canvas(document.body).then(function(canvas) {
        var imgData = canvas.toDataURL("image/jpeg", 1.0);
        var pdf = new jsPDF('p', 'mm', [400, 480]);
        pdf.addImage(imgData, 'JPEG', 20, 20);
        pdf.save("screen-3.pdf");
    });
});

Most helpful comment

After years ...
Should be:

$(document).on("click", ".download-pdf", function() {
    html2canvas(document.body).then(function(canvas) {
        var imgData = canvas.toDataURL("image/jpeg", 1.0);
        var pdf = new jsPDF('p', 'mm', [400, 480]);
        pdf.addImage(imgData, 'JPEG', 0, 0, 400, 480);
        pdf.save("screen-3.pdf");
    });
});

>All comments

After years ...
Should be:

$(document).on("click", ".download-pdf", function() {
    html2canvas(document.body).then(function(canvas) {
        var imgData = canvas.toDataURL("image/jpeg", 1.0);
        var pdf = new jsPDF('p', 'mm', [400, 480]);
        pdf.addImage(imgData, 'JPEG', 0, 0, 400, 480);
        pdf.save("screen-3.pdf");
    });
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sayo96 picture sayo96  路  3Comments

centurianii picture centurianii  路  4Comments

Pinank picture Pinank  路  3Comments

allenksun picture allenksun  路  3Comments

baluMallisetty picture baluMallisetty  路  4Comments