Martin Paul Eve bio photo

Martin Paul Eve

Professor of Literature, Technology and Publishing at Birkbeck, University of London

Email Books Twitter Github Stackoverflow MLA CORE Institutional Repo ORCID ID  ORCID iD Wikipedia Pictures for Re-Use

tl;dr: use the node.js module html-pdf-chrome to print programmatically, not Chrome’s built-in virtual-time-budget. See my print.js file for an example.

My CV is generated automatically from Birkbeck’s online repository. It uses a system that basically generates a paginated version of the CV in the browser, using CSS regions technologies, then does a headless print via Chrome. All the source code is available for this.

The problem is that Chrome has an option to wait until the page has fully rendered before printing. If you Google it, you’ll get the answer that you should use the –run-all-compositor-stages-before-draw and –virtual-time-budget=10000 flags.

However, these do not work in the case of my CSS regions work. Regardless of how high I set the virtual time budget, on ultra-fast hardware, Chrome truncated the PDF.

I finally found a new solution in the node.js module html-pdf-chrome. You can see how this is now called inside my print.js file but, essentially, this allows for a timed completion trigger before it sets off the print. Setting this to 5000ms was more than adequate for my purpose.