Skip to content

Commit

Permalink
Fix issue where resource loading was not finished before rendering di…
Browse files Browse the repository at this point in the history
…rect html. More here puppeteer/puppeteer#728
  • Loading branch information
kimmobrunfeldt committed Oct 13, 2017
1 parent 005a7da commit 7aee56d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ is really simple, check it out. Render flow:
3. Render url **or** html.

If `url` is defined, **`page.goto(url, options)`** is called and options match `goto.*`.
Otherwise **`page.setContent(html)`** is called where html is taken from request body.
Otherwise **`page.goto(\`data:text/html,${html}\`, options)`** is called where html is taken from request body. This workaround was found from [Puppeteer issue](https://github.com/GoogleChrome/puppeteer/issues/728).

4. *Possibly* **`page.waitFor(numOrStr)`** if e.g. `waitFor=1000` is set.
5. *Possibly* **Scroll the whole page** to the end before rendering if e.g. `scrollPage=true` is set.
Expand Down
3 changes: 2 additions & 1 deletion src/core/pdf-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ async function render(_opts = {}) {

if (opts.html) {
logger.info('Set HTML ..');
await page.setContent(opts.html);
// https://github.com/GoogleChrome/puppeteer/issues/728
await page.goto(`data:text/html,${opts.html}`, opts.goto);
} else {
logger.info(`Goto url ${opts.url} ..`);
await page.goto(opts.url, opts.goto);
Expand Down

0 comments on commit 7aee56d

Please sign in to comment.