While generating pdf, landscape option doesn't work
See original GitHub issueSteps to reproduce
Tell us about your environment: We are trying to generate pdf using puppeteer. Previously we had the landscape option working on Puppeteer 1.5.0 and node 8.9.4. But, after we moved around the code and updated the node and puppeteer versions to 8.15.0 and 1.11.1 respectively, the landscape option tends to generate a portrait instead of a landscape.
- Puppeteer version: 1.11.1
- Platform / OS version: ubuntu
- URLs (if applicable):
- Node.js version: 8.15.0
Please include code that reproduces the issue.
function generatePDF(html, options) { // options has landscape param set to true or false browser = await puppeteer.launch({ args: this.puppeteerArgs }); page = await browser.newPage(); const session = await page.target().createCDPSession();
await session.send('DOM.enable');
await session.send('CSS.enable');
await page.goto(`data:text/html,${html}`, { waitUntil: 'networkidle2' });
this.logger.debug('generatePDF - creating pdf buffer..');
const buffer = await page.pdf(options);
await page.close();
await browser.close();
return buffer;
} What is the expected result? generates a landscape view
What happens instead? generates a portrait view
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:15
Top Results From Across the Web
Rotation problem when creating PDF | Adobe Acrobat
Rotation problem when creating PDF · 1. Choose File > Export · 2. In the Export dialog, choose Adobe PDF · 3. When...
Read more >PDF won't deal with Word landscape pages properly
I tried several things — re-creating the PDF using Acrobat, using Word's PDF option, fiddling with the settings in Acrobat etc. all to...
Read more >Microsoft Print To PDF Option Changes Page Orientation To ...
1. Open the Tools menu, locate its Pages submenu and choose "Rotate" to open the Rotate Pages dialog box. · 2. Change the...
Read more >[Solved] Headless Chrome options ignoring landscape mode ...
NET client library was not generating his PDFs in 'landscape' mode while using Headless Chrome. The customer provided all of their C# code ......
Read more >Landscape mode when printing to pdf - ROOT Forum
hi, In an application, I save the canvas plots as a pdf document using the method: C->Print("C.pdf"); The output file is in portrait...
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 FreeTop 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
Top GitHub Comments
Have you tried altering the CSS rule
@page
?Edit: You can use the CSS rule only for Puppeteer:
I’m using PuppeteerSharp v1.20.0. I confirm that landscape option doesn’t work. Explicitly setting page width & height didn’t work also. However, using page.addStyleTag worked for me. You can try page.addStyleTag( {‘content’: ‘@page { size: A4 landscape; }’} )