page.pdf generating different and unexpected content with chrome print
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 2.1.1
- Platform / OS version: macOS Catalina 10.15.4
- URLs (if applicable): https://github.com/rawbin-/puppeteer-test-pdf
- Node.js version: 12.14.0
What steps will reproduce the problem?
use https://github.com/rawbin-/puppeteer-test-pdf
see the data folder, or run the test-from-html.js
or you can do with the ReadMe.md
Please include code that reproduces the issue.
const path = require('path')
const puppeteer = require('puppeteer')
const DEFAULT_ARGS = [
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-first-run',
'--no-sandbox',
'--no-zygote',
'--disable-extensions',
'--disable-webgl'];
const htmlPath = './data/test-simple.html'
const format = 'A5' // alt A5 A4
setTimeout(async () => {
const htmlPathAb = path.resolve(htmlPath)
const pdfPath = `${htmlPathAb}-${format}.pdf`
const browser = await puppeteer.launch({
args: DEFAULT_ARGS,
});
const page = await browser.newPage()
console.log('opening the page')
await page.goto(`file:///${path.resolve(htmlPath)}`, {
waitUntil: 'networkidle0',
timeout: 60000 * 10 // 尝试性加入最大等待时间,可能还不够。。。
})
console.log('waiting for the page')
await page.waitForFunction(() => {
return window.contentRenderFinished
});
console.log('generating pdf')
await page.pdf({
htmlPath: htmlPathAb,
path: pdfPath,
format: format,
printBackground: true,
landscape:true,
margin: {
top: '23.13mm',
bottom: '25mm',
left: '0mm',
right: '0mm'
}
});
await page.close();
await browser.close()
console.log('finished')
}, 5000)
What is the expected result?
chrome print ok
chromium print ok
puppeteer generate ok
no content splited into two pages
What happens instead?
chrome print ok
chromium print ok
puppeteer generate not
one line splited into two pages
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
Printing PDF from web browser gets weird - HP Community
This only happens when printing a pdf file from the web browser (Google Chrome, have not tried other browser): if I download the...
Read more >90340 - Chrome crashes when printing to PDF - chromium
I have tried printing to a pdf, actually printing the page. Tried printing text urls, pdfs, urls containing flash pages. Chrome dint crash...
Read more >Chrome is suddenly defaulting to PDF to print. - Google Help
When previewing documents via Chrome PRINTER icon in top right hand corner of window the print is always directed to download the file...
Read more >Trouble printing adobe .pdf files on google chrome
The current version of Chrome doesn't use the Adobe Reader to display PDF files. When you hover your mouse over the bottom left...
Read more >Google Chrome Printing Page Breaks - css - Stack Overflow
I've used the following approach successfully in all major browsers including Chrome: <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" ...
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
The fonts are different.