Closed lidkxx closed 2 years ago
After the correction I made, the images were rendered correctly:
In your approach there were some bugs that I fixed. Try to make a new PR.
The problem can be fixed using the native puppeteer function called waitFor()
.
if (waitForRender) {
// Todo: remove this sentence
// await new Promise((r) => setTimeout(r, waitFor));
await page.goto(`${nextPageURL}`);
console.log(chalk.green('Rendering...'));
await page.waitFor(waitFor);
} else {
// Go to the page specified by nextPageURL
await page.goto(`${nextPageURL}`, {
waitUntil: 'networkidle0',
timeout: 0,
});
}
Make the same changes as above and create a new PR.
Yeah, your solution is a bit more sophisticated. Thanks for looking at mine! Amended in my last commit.
I've left the waitForRender
option as number
still, or do you think it's better off as a string
?
I'm glad you liked my suggestions 😅.
About the waitForRender attribute typing by default it is a string, this is how commander sets the values.
Would love to see this get merged, as we're running into problems with images not rendering.
@lidkxx super thanks for your PR, and sorry for my late response.
Our app documentation is around 140 pdf pages with a lot of images. During a pdf generation using mr-pdf script I would encounter two problems:
Seems we just need a bit of a timeout to let the script glue all the html content it downloads from the docusaurus pages.
I've added
--waitForRender
option that takes anumber
value of ms in case anyone encounters a similar problem. (I am sure this won't be necessary for lightweight docs that don't have too many images).This fixes #28