Szpadel/chrome-headless-render-pdf

Force Chrome to wait before PDF print

gryphonshafer opened this issue · 4 comments

Thank you for this very useful software.

I have a use case where I need to force Chrome to wait before it prints a PDF. The page itself needs to run some Javascript and complete this work prior to printing. I've tried passing virtual-time-budget, but it seems to have no effect. The log output returned from chrome-headless-render-pdf includes the following:

Wait for js execution took 1ms

Is there a flag or other setting I can use with chrome-headless-render-pdf to force Chrome to wait for perhaps 2000ms before printing to PDF?

Is this some server side initiated resource? vietual-time-budget simulate all time events (setTimeout etc) to happen up to that time as fast as possible, therefore it will take much less than that time, but it should have the same effect as really waiting that time when all time related logic is happening in browser

The page I'm trying to PDF has some Javascript on it that needs between 1 and 2 seconds to run (which manipulates content in the DOM a bit). Regardless of what I've tried thus far, the rendered PDFs all have only the first couple of ms-worth of that Javascript's work completed. What I'm trying to do is force Chrome to not print for 2000ms.

This may be something in chrome(ium) and not something chrome-headless-render-pdf can do. But I'm not finding a solution other than using something like Puppet directly.

any news on this? I also stuck with the same problem.
Having a page which does call an external REST Api and needs 1-2 seconds to finish.
The screenshot always only contains the progress bar which is shown when page is started.
My code

RenderPDF.generateMultiplePdf(
 [{ url: "https://mywebpage/", pdf: "/tmp/outputPdf.pdf" }],
   {
     chromeBinary: "/usr/bin/chromium",
     chromeOptions: ['--no-sandbox', '--virtual-time-budget','2500']
   })

also tried

RenderPDF.generateMultiplePdf(
 [{ url: "https://mywebpage", pdf: "/tmp/outputPdf.pdf" }],
   {
    chromeBinary: "/usr/bin/chromium",
    chromeOptions: ['--no-sandbox', '--virtual-time-budget=2500']
   })

chrome-headless-render-pdf seems to disrespect this chrome option

U added new option to set increase time budget --js-time-budget from default 5s
from api its jsTimeBudget