Chrome-remote-interface: Page.printToPdf & HeadlessChrome

Created on 15 Apr 2017  路  2Comments  路  Source: cyrus-and/chrome-remote-interface

Hey Andrea,

I just discovered this project and I must say: thanks, this is awesome! :heart_eyes:

I tried to use the very very new Page.printToPdf. The local protocol.json doesn't have the method yet so I used CDP({ remote: true }.... The problem I encountered is that it triggers the version fetching and the regex for Chrome is a strict /^Chrome\// which does not work with Chrome with the --headless option. When I start it like this, the browser variable is equal to HeadlessChrome/59.0.3067.0.

I patched it locally with /^Chrome\// to test and printToPdf worked but maybe you want to fix that differently like adding a new else if.

WDYT?

bug

Most helpful comment

Thanks Hubert, I really appreciate it! :)

Yes, this was related to this issue but it seems that it has been fixed now. Thanks for reporting.

Fixed and pushed a new version on NPM ([v0.19.0]).

FYI: you don't really need the proper protocol if you're aware of the capabilities of the implementation, you can simply use the other syntax, for example:

client.send('Page.printToPdf')

In fact, you should avoid the remote option unless really needed, because (at least for Chrome/ium) it involves 2 HTTP requests.

Anyway I've fetched the latest version of 'protocol.json' as well which includes Page.printToPdf.

All 2 comments

Thanks Hubert, I really appreciate it! :)

Yes, this was related to this issue but it seems that it has been fixed now. Thanks for reporting.

Fixed and pushed a new version on NPM ([v0.19.0]).

FYI: you don't really need the proper protocol if you're aware of the capabilities of the implementation, you can simply use the other syntax, for example:

client.send('Page.printToPdf')

In fact, you should avoid the remote option unless really needed, because (at least for Chrome/ium) it involves 2 HTTP requests.

Anyway I've fetched the latest version of 'protocol.json' as well which includes Page.printToPdf.

Thanks for the new version and for the client.send() tip :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mic75 picture Mic75  路  4Comments

elsigh picture elsigh  路  3Comments

fracasula picture fracasula  路  6Comments

jimut picture jimut  路  7Comments

zirill picture zirill  路  6Comments