creating pdf from html+css creates empty files
See original GitHub issueSteps to reproduce
I want to generate a pdf document from html and css (also images and files in general). For now I am using phantomjs which is compared to puppeteer rather easy and straight forward, but due to maintenance reasons I want to move away from phantomjs. My pdfs are for some reason only blank. What is strange is, that when i remove all the <h#>-tags atleast a part of the html is correctly converted to the pdf. So there might be a bug for headlines? Also, how can multi-page pdfs created, the generated file consists of at most 1 page for me.
Tell us about your environment:
- Puppeteer version: 5.3.0
- Platform / OS version: Ubuntu 20.04
- Node.js version: 10.19.0
var browser = await puppeteer.launch();
var page = await browser.newPage(); //only 1 page, but i cannot add pages manually all the time obviously
await page.emulateMediaType('print');
await page.goto(`data:text/html,${html}`, {waitUntil: 'domcontentloaded'});
await page.pdf({path: `/tmp/${filename}`, format: 'A4'});
await browser.close();
What is the expected result?
Multi-page pdf which is generated from my html and css and embeds my local files correctly.
What happens instead?
- files are not embedded (do not really know how to set them as resources for the generation?)
- only one empty page is generated (unless I remove all headline-tags from the html
- css is not applied
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
html - PDF::FromHTML creates empty PDF - Stack Overflow
my $pdf = PDF::FromHTML->new( encoding => 'utf-8' ); # Loading from a file: $pdf->load_file('source.html'); # Perform the actual conversion: $ ...
Read more >Convert HTML to PDF not working - Power Platform Community
Hey guys,. I'm trying to convert an html to pdf, my html is fine but my pdf file is always blank. What am...
Read more >empty PDF - Google Groups
Hi there, For an unknown reason the PDF I generate from an XHML is just empty. The XHTML is apparently well parsed, the...
Read more >HTML to PDF Javascript: Export HTML/CSS To PDF Using ...
I will show you guys step by step procedure to export the content of HTML/CSS into Pdf Document (HTML to pdf javascript).
Read more >How To Create a Download Link - W3Schools
Learn how to create a download link with HTML. ... automatically detect the correct file extension and add it to the file (.img,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have the same issue with blank pdfs. I’m not using
page.goto
since there is thepage.setContent()
method. But it doesn’t render the pdfs.Here is my code:
Puppeteer version:
puppeteer-core: ^5.3.1
Platform: macOS / AWS Lambda Node.js version :12.x
Full repo: https://github.com/softwarebrauerei/pdf-renderer
We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!