PDF generation fails due to font loading timing; document.fonts.ready offers fix
A developer encountered an issue where PDFs generated from a web page appeared blank or with incorrect fonts. The problem occurred because the script generated the PDF immediately after the page's 'load' event, which does not wait for web fonts to finish downloading. Testing revealed that both remote fonts from Google Fonts and locally bundled fonts were not fully loaded when the PDF was created. The developer resolved the issue by using the `document.fonts.ready` promise, which ensures all fonts are loaded before generating the PDF.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in