-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NODRIVER] How to print to pdf in print preview? #2112
Comments
Hi! I had a similar experience trying to automate printing web pages as PDF. In my case, I used Selenium with the standard ChromeDriver. Maybe this can help you solve your problem. Chrome Options Configuration to Save as PDFI used Chrome options to configure the printing behavior. Specifically, I set the preferences to make "Save as PDF" the default destination and enabled automatic printing. Here's an example:
This configuration allows Chrome to skip the "Print Preview" interface and save directly as a PDF. Script to Print the PageAfter configuring ChromeDriver with these options, I used the following command in Selenium to trigger the page print:
Notes
I hope this helps or gives you some ideas to solve your issue! Let me know if you need more details. 😊 |
Hello again! I tested the method mentioned earlier using undetected-chromedriver and successfully made it work. When using undetected-chromedriver, the only change required was replacing the creation of Chrome options. I substituted:
with:
This change is essential because undetected-chromedriver uses its own implementation for handling browser options, compatible with detection bypass. Note on the detach Option.
If you are using this setting, you’ll need to remove it when switching to undetected-chromedriver. |
I'm trying to automate the download of a quarterly PDF. The built-in printing function of the webapp opens an HTML view in a new window and goes to print preview (print() function).
Is there a way to automate "save to PDF"?
The text was updated successfully, but these errors were encountered: