[BUG] PDF is blank
See original GitHub issueEnvironment
chrome-aws-lambda
Version: 2.0.2puppeteer-core
Version: 2.0.0Node.js
Version: 10.xLambda / GCF Runtime
: 10.x
Expected Behavior
Should print a simple H1 tag
Current Behavior
PDF is blank
Possible Solution
Steps to Reproduce
const html = '<html><head><title>Test</title></head> <body> <h1> Testing. </h1></body></html>';
const browser = await chromium.puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: chromium.headless,
});
const page = await browser.newPage();
page.setContent(html);
const pdf = await page.pdf({
format: 'A4',
printBackground: true,
margin: {
top: '1cm',
right: '1cm',
bottom: '1cm',
left: '1cm',
},
});
await s3.upload({
Body: Buffer.from(pdf.toString('base64'), 'base64'),
Bucket: 'bucket-name',
Key: 'prints/test.pdf',
}, (err, data) => {
if (!err) {
console.log('Data: ', data);
} else {
console.log('Error: ', err);
}
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Best Solutions to Fix Blank PDF File Problem
The incompatible or outdated software version is the primary reason for errors in PDF files, especially blank pages. That's why you must update ......
Read more >PDF pages go blank - Adobe Support Community - 8352938
Solved: When using adobe acrobat pro dc and I leave a pdf open and untouched. The page I am viewing goes blank as...
Read more >5 Simple Ways to Fix PDF Is Blank When Opened Today
1. The PDF file is not available in the virtual directory. · 2. Poor internet connection or large file download done incorrectly. ·...
Read more >Top 3 Methods to Resolve PDF Blank Pages Problem Manually
Top 3 Methods to Resolve PDF Blank Pages Problem Manually · Method 1. Verify is the Web Server is Valid or Not ·...
Read more >Blank pages displayed when viewing large PDF - IBM
This error occurs when an object in the PDF document is incomplete, or when an object is missing a key element. Frequently, the...
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
@nyel-dev Apologies for the delay in the reply. I changed your code slightly:
Which returns the expected base64-encoded PDF:
Perhaps the issue could be that you are not waiting for
page.setContent
to resolve?@alixaxel
await page.setContent
fixed it. Thanks.