Hi, Thanks for the article. I have an issue where the pdf comes empty randomly, to solve it setContent should wait for everything to be loaded.
setContent
await page.setContent(html, { waitUntil: ['load', 'domcontentloaded', 'networkidle0'] });
Thanks :) Very good point and interesting find. I haven't seen this when loading html as string but this very well can happen.
WaitUntil is very good to use and even necessary if page itself loads external content.
i tried following this step but the page of the PDf is still empty
Do you have some content that is loaded conditionally and could cause the issue? I have seen that if there is enough long gap between two loading elements, Puppeteer will treat the page final before all the data has been loaded.
Thanks for your comment! I had the same issue trying to run puppeteer in a EC2 linux instance but with your adjust it is working now.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
Thanks for the article.
I have an issue where the pdf comes empty randomly, to solve it
setContent
should wait for everything to be loaded.Thanks :) Very good point and interesting find. I haven't seen this when loading html as string but this very well can happen.
WaitUntil is very good to use and even necessary if page itself loads external content.
i tried following this step but the page of the PDf is still empty
Do you have some content that is loaded conditionally and could cause the issue? I have seen that if there is enough long gap between two loading elements, Puppeteer will treat the page final before all the data has been loaded.
Thanks for your comment! I had the same issue trying to run puppeteer in a EC2 linux instance but with your adjust it is working now.