AmirTugi / tea-school

Simplified HTML + CSS --> PDF Generator for Nodejs
343 stars 31 forks source link

[Possible solution] puppeteer is rendering blank #10

Closed leonimurilo closed 5 years ago

leonimurilo commented 5 years ago

I was trying to use the lib but in every test the output was a blank pdf.

I tried to debug the code and the solution I found was replacing

await page.goto('data:text/html,${renderedTemplate}/', { waitUntil: ['load', 'domcontentloaded', 'networkidle0'] });

by

await page.setContent(renderedTemplate);

I don't know if I was using different versions of the dependencies but I am just sharing the solution I found.

manojchandrashekar commented 5 years ago

This worked for me too. Thanks!

AmirTugi commented 5 years ago

I'm trying to run this locally, and it fails. @leonimurilo can you provide me maybe with an environment where it is reproduced? What kind of content you're trying to convert? I'm getting Error: Protocol error (Page.navigate): Cannot navigate to invalid URL undefined if I'm using your solution.

manojchandrashekar commented 5 years ago

Don't know about @leonimurilo, but I'm using it on a Windows 10 machine with nodejs v10.13. These are the installed versions of the dependencies: node-sass: 4.11.0, pug: 2.0.3 and puppeteer: 1.14.0

AmirTugi commented 5 years ago

What kind of content are you trying to render? Is it HTML? Can you try to maybe fork the repo and run the tests? I'm just not able to reproduce this.

leonimurilo commented 5 years ago

My environment was: macOS Mojave node.js >=8.9.0 I was using @babel

I was rendering a simple html.

AmirTugi commented 5 years ago

Can you please provide an environment where it is reproduced?

AmirTugi commented 5 years ago

Closing for now, as no reproduction env is supplied (I couldn't reproduce the issue).