-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add option to wait for document render #36
Conversation
helps when the script is rendering large pdfs with a lot images. this fixes kohheepeace#28
🐱💻 Fixing...Result: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. 🚀 Correct approachThe problem can be fixed using the native puppeteer function called 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing it with (see conversation):
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,
});
}
Yeah, your solution is a bit more sophisticated. Thanks for looking at mine! Amended in my last commit. I've left the |
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