it is not possible to generate a pdf with a single page with the full height of the page.
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 2.1.1
- Platform / OS version: mac OS Catalina 15.3
- URLs (if applicable): https://flutter.dev/docs/development/ui/widgets-intro
- Node.js version: v13.12.0
What steps will reproduce the problem?
just compile.
Please include code that reproduces the issue.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://flutter.dev/docs/development/ui/widgets-intro', {waitUntil: 'networkidle2'});
page.evaluate(() => {
let container = document.querySelector('.container');
if (!container) {
container = document.querySelector('#content')
}
let html = document.querySelector('html');
let body = document.querySelector('body');
let classe = body.classList
let clone = container.cloneNode(true)
html.removeChild(body);
body = document.createElement("body").appendChild(clone)
body.classList = classe
html.appendChild(body)
});
await page.emulateMedia('screen')
let height = await page.evaluate(() => document.documentElement.offsetHeight);
await page.pdf({path: 'mypdf.pdf',printBackground: true, height: height + 'px', width: '210mm'});
await browser.close();
})();
What is the expected result?
a pdf file with a single page of the total height of the url
What happens instead?
a pdf is generated with two pages
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Scale or resize printed pages in Acrobat and Reader
Automatically scale to fit paper Acrobat can size the pages of a PDF to fit the selected paper size. Choose File > Print....
Read more >HOW TO SET DEFAULT PAGE MAGNIFICATION IN ADOBE ...
Click Ok to apply new settings. Now, open a few PDF documents to check whether the new page display settings are working. Create...
Read more >How to Change Scale Ratio in PDF
How you scale or resize the PDF depends on whether it's a single page or not. Single pages can usually be scaled just...
Read more >How to Change PDF Page Size in Adobe Acrobat
No, Adobe Acrobat cannot create a custom-sized page because it does not have the feature of Adobe PDF page size dimensions in it....
Read more >PDF Files - NETT
Page 1 of 4. PDF Files. Scan – Create – Reduce File Size. It is recommended that you purchase an Adobe Acrobat product...
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
@mcama I have a solution for you. but not sure if it works for you. Just working fine for me. Try with the below code for making a single page pdf. Hopefully, it’ll work.
Note: Don’t worry about ejs rendering it’s for making dynamic HTML. Make sure you’re properly getting the height of the page.
Here, boundingBox object contains
{ x: 0, y: 0, width: 1280, height: 1235 }
information. So here the magic happened 👍 .We no longer support Node < 14, please try this again with the latest version of Puppeteer and Node >= 14. If the issue still occurs, please reopen this issue and update the description 😃