Protocol error (Page.printToPDF): Show invalid printer settings error, thrown while printing pdfs
See original GitHub issueSteps to reproduce
- Puppeteer version: 6.14.7
- Platform / OS version: Ubuntu 18.04.5 LTS
- Node.js version: v14.8.0
- local-chromium: linux-782078
Prerequisites Have two similar methods, which generate pdf, calling page.pdf() Example functions:
async printFolderQrCode(folderId) {
const page = await this.openNewPage();
const pdfPath = ...;
const uri = new URL(...t);
uri.search = ...;
await page.goto(uri);
await page.pdf({ path: pdfPath });
await page.close();
return pdfPath;
}
`
`
async printDocumentTypeQrCodes() {
const page = await this.openNewPage();
const pdfPath = ...;
const uri = new URL(...);
uri.search = ...;
await page.goto(uri);
await page.pdf({ path: pdfPath });
await page.close();
return pdfPath;
}
Execution Executed the functions in both ways sync and async (using Promeise.all())
Expected result? Two pdfs are stored on the fs, and the methods return their paths.
Actual result Sometimes, the execution results in failure, with exception thrown:
Error: Protocol error (Page.printToPDF): Show invalid printer settings error
at /home/dbonchev/Documaster/wfc/software/automation/wfc-test-automation/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:208:63
at new Promise (<anonymous>)
at CDPSession.send (node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:207:16)
at Page.pdf (node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1152:43)
In 2/3 of the executions, everything is OK, and pdfs are printed, but in 1/3 of the cases the error above is thrown. This anomaly has appeared, once I updated the puppeteer version @latest.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9
Top Results From Across the Web
chromedp - Go - Show invalid printer settings error (-32000)
The error message can be interpreted as "I can not show a dialog to alert the user that the provided printer settings are...
Read more >Gettting Error while trying to create pdf using browserhot
Fixed. We were executing command called window.print();.
Read more >How to Fix the "Windows PDF Printer Error: Invalid Font When ...
Type Adobe Acrobat Reader in the Start Menu search bar and select the Best match. Click Edit in the top-left corner and then...
Read more >About to lose my mind trying to get Page.printToPDF to work ...
Should be valid HTML markup with following classes used to inject printing values into them: date : formatted print date; title : document...
Read more >Known issues with PaperCut MF, NG, Hive, Pocket and ...
Google Cloud Directory certificate import fails while setting up user sync ... Print Deploy Client may show "Can't reach this page" error on...
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

To resolve my problem, im using many of code (try/catch) validation and looping. Every important code, im using while with try/catch , and break with my code if it not return error on my try catch. Following this way, every error returned maping or not, go to my initial global looping and make all again and again.
}
Found the original problem: We were calling
window.print()at the start of the document load which creates a collision between puppeteer trying to “print” a PDF and the printing dialog created by Javascript call (window.print()).