• I love your product and it creates great PDF reports, but they download as attachments. I'd like the PDF to display in a print preview like popup where the user can either save the rendered PDF as an attachment or print directly from there. I found a great open source JavaScript library called Print.js (npm install print-js) that does just that (examples). I can't imagine I'm the first person that wants to try to use both these great tools together. I searched online and this forum and found nothing. Before I try to integrate them myself I thought I'd first ask if anyone else has tried it and if so, is there any example code?

  • I was able to get it working very easily. I post the JSON using XMLHttpRequest() and create a Blob using the response. Print.js can understand the response. The only problem is the option to set the filename when saving as PDF isn't working, but it's currently an issue on Github and hopefully will be addressed soon.

    var pdfFile = new Blob([this.response], { type: "application/pdf" });
    var pdfUrl = URL.createObjectURL(pdfFile);
    printJS({ printable: pdfUrl });

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.