0

I'm willing to invite all my friends to my wedding, I have all the addresses in an Excel and I made a postcard in html using jQuery and urlParams to make every postcard personal.

Now I am stuck at the point where I want to turn all the pages into PDFs to print them (I'd like to have one big PDF with page 1 guy1 front, page 2 guy1 back, page 3 guy2 front and so on...)

I've tried with jspdf like this:

var doc = new jsPDF('landscape','pt');
doc.fromHTML(documtent.body,100,100,{});
doc.save('bigpdf');

but it gets my html all messed up and it doesn't look like on browser (and it has no background)

I've also tried html2canvas:

html2canvas(document.body).then(canvas => {
    saveAs(canvas, 'bigpdf');
});


function saveAs(uri, filename) {

    var link = document.createElement('a');

    if (typeof link.download === 'string') {

        link.href = uri;
        link.download = filename;

        //Firefox requires the link to be in the body
        document.body.appendChild(link);

        //simulate click
        link.click();

        //remove the link when done
        document.body.removeChild(link);
    } else {
        window.open(uri);
    }
}

but the downloaded file has no <p> tag on it nor QR code (I made a qr code to track who is coming)

I hope you'll find my solution

Many thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Since you use `document.body` I assume your styles are in `head`, so no styles applied for that reason – Justinas Jul 15 '20 at 08:05
  • 1
    Does this answer your question? [Exporting web page into PDF using jsPDf](https://stackoverflow.com/questions/19783721/exporting-web-page-into-pdf-using-jspdf) – Justinas Jul 15 '20 at 08:06
  • no, i get the same error, "Not allowed to navigate top frame to data URL" – Rudy Quinternet Jul 15 '20 at 08:42
  • Check this answer: https://stackoverflow.com/questions/45493234/jspdf-not-allowed-to-navigate-top-frame-to-data-url – Justinas Jul 15 '20 at 10:04
  • Any sample codesandbox/jsfiddle link that you can provide mimicking what exactly is breaking for you? – Pawan Singh Jul 15 '20 at 18:31

0 Answers0