jsPDF icon indicating copy to clipboard operation
jsPDF copied to clipboard

How to generate / download pdf from HTML

Open shujaatxp opened this issue 8 years ago • 4 comments

var pdf = new jsPDF('p', 'pt', 'a5');

    var canvas = pdf.canvas;
    canvas.height = 72 * 11;
    canvas.width = 72 * 8.5;

    html2pdf(document.body, pdf, function (pdf)
    {
        var iframe = document.createElement('iframe');
        iframe.setAttribute('style', 'position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
        document.body.appendChild(iframe);
        iframe.src = pdf.output('datauristring');
      
    }
    );

shujaatxp avatar Feb 20 '18 06:02 shujaatxp

I have an html page with CSS styling. this page will be used as an certificate page. i want to download the html certificate as it is with it styling. previously i was using addhtml. english was working fine with that, however, arabic was scarambling.

shujaatxp avatar Feb 20 '18 06:02 shujaatxp

Imho a perfect html to pdf will not work and arabic support is right now not implemented.

Uzlopak avatar Feb 20 '18 06:02 Uzlopak

Oh, what is the alternate in this case.

shujaatxp avatar Feb 20 '18 06:02 shujaatxp

Separate the model layer and write separate view-layers, one normal HTML and one jsPDF. Meaning: Write it complete new in jsPDF.

Uzlopak avatar Feb 21 '18 10:02 Uzlopak