Webpage to PDF

  • Dear jsreport team,

    We're considering jsreport for our projects, but there's just one thing holding us back:

    • Can we use jsreport for server-side pdf redering of web pages (developed in angular or react)?

    Most of our reports would be PDF or Excel renderings of grids we have on screen. For most reports, we don't want to rewrite the corresponding angular screens in some other templating engine in jsreport. Instead we intend making our screens printable. In this scenario, we would pass some URL to jsreport and expect jsreport to render the corresponding angular page to a PDF and return it.

    We could build the same with some flavor of headless chrome such as browserless, but we think jsreport has interesting extra capabilities built-in such as TOC, PDF encryption, Excel-based templating, etc. That we'd love to use for some more sophisticated reports.

    Do you think jsreport can be used as a chrome-based server-side PDF renderer? If yes, how would that work?

    Best regards,


  • jsreport can fetch a URL using the custom script and print it.
    You can try to fiddle with this demo and your pages.

  • Thanks, we'll give it a try.

  • It doesn't work well for js web apps. For instance:

    It seems jsreport is not waiting for the page to be visually complete.

    Is there additional options to tick or pass to the request function?

  • Hello, I'm trying to use the guidance provided in this thread to fetch a PDF for an Angular application, but without success. From what I can observe, the fetch mechanism loads only the HTML file, and doesn't load the JS scripts linked in this HTML file. The printing triggers etc. do not have an influence on this behaviour. Is there any flag that says ti JS report that it should load linked JS files as well?

  • The mentioned example is downloading html, explicitly setting html base tag and let it evaluate by chrome.
    In normal cases, this is enough. The js and styles are properly evaluated.

    Unfortunately, this breaks for the previously linked angular apps, because they are behind github web server that sends X-Content-Type-Options: nosnif headers and doesn't allow us to do this trick. However, normally it should work as mentioned.

  • administrators

    we released a new version of chrome-pdf extension that can generate PDF from an URL.

    to use it use an script that does the following:

    function beforeRender(req, res) {
      req.template =  req.template || {} 
      req.template.chrome =  req.template.chrome || {} 
      req.template.chrome.url = 'http://your-page-here.com'

  • Awesome! Can we try it out in the playground ?

  • No, you need to spin your own instance and update jsreport-chrome-pdf extension to the latest version
    npm i jsreport-chrome-pdf@1.5.0

  • Thanks a lot. We were able to run some successful tests.

    Now we'll spend some time implementing a full printing scenario with out app.

Log in to reply

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