How to print current opened page as PDF file?

698 views
Skip to first unread message

yuis

unread,
Aug 28, 2018, 11:03:15 PM8/28/18
to Selenium Users


Hello.

I'm using selenium webdriver on Ruby.

I want to print PDF file on chrome on selenium.
But I have two problems.

1. There is no way to click "print" button automatically. JavaScript not works.
2. My Windows PC connecting with some printers. In printing page on chrome on selenium, default selecting printing method is not a PDF but the printer.

How do I do it?

Serguei Kouzmine

unread,
Aug 29, 2018, 9:20:32 PM8/29/18
to Selenium Users
Hello yuis

example

```
chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/
```
If i am not mistaken it uses CDP

under the hood but is used simply as a process with arguments  
Reply all
Reply to author
Forward
0 new messages