Issue metadata
Sign in to add a comment
|
headless: Support printing PDFs in screen mode.
Reported by
daudmali...@gmail.com,
Jul 10 2017
|
||||||||||||||||||||||
Issue descriptionuntil the latest version of chrome 59 , when we convert loaded page to pdf using flag --print-to-pdf it converts the page to pdf and look like as the print function available in chrome gui , but i think it would be more better to convert loaded page to pdf as it can be seen on chrome browser regardless of @media print css of put some flag e.g --print-to-pdf-real as they have implemented in wkhtmltopdf http://wkhtmltopdf.org/ Thanks & Best Regards
,
Jul 12 2017
If I understand correctly, you would like to render a PDF in CSS media screen mode, rather than print mode?
,
Jul 12 2017
sorry for some typos , yeah you understood more o less, actually i want to render a pdf regardless of CSS media, it should be rendered as we can see it in chrome gui . example :: there are html pages with css with media=print queries and when chrome render that html that ignores those print queries because it's in screen mode and when we use ctrl+p(print) it render that page using CSS media=print queries . so i want if it's possible to just ignore those print queries and always use screen queries like how chrome render html to display on screen that pdf functionality would be doing exactly same. is that possible or any future hope for this ? was i able to make you understand ? Thanks & Best Regards
,
Jul 12 2017
Yeah, I think I understand. Not sure if it's easily to add. thestig@ may know if there's currently a way to generate a PDF in screen mode.
,
Jul 12 2017
alright let's wait for his reply Thanks :)
,
Jul 12 2017
Alternatively one could take screenshots of the page as PNG and then convert those screenshots to PDF.
,
Jul 12 2017
@paulir yeah this will be my move if that option is not available , but it will be really nice if there is such option , like --print-to-pdf --media=screen of whatever media user wants what do you guys think ?
,
Jul 12 2017
As I understand it there are a couple benefits to printing to PDF over converting PNGs to PDF: * Links work and text can be highlighted (I haven't tested, but this may also mean the file size is smaller) * Paginated layout avoids stuff getting spliced across pages (which is actually bad if you want to 100% reproduce how Chromium shows stuff on a screen; but generally a good thing for decent looking paginated media)
,
Jul 12 2017
yeah in-fact there are some benefits .
,
Jul 12 2017
If you want to do this, I would recommend writing a (or installing a pre-existing) Chrome extension to manipulate the page and take away the print CSS.
,
Jul 13 2017
really cool solution thanks a lot , so any suggestion for extension or anyway how to change loaded css using chrome headless without debugging mode .?
,
Jul 13 2017
FYI, headless doesn't support chrome extensions, so any style removing would have to be done via devtools.
,
Jul 13 2017
thanks for your solution it really works , anyway i've found this solution(see attachment) using gui chrome , so any idea how to achieve the same using cli ?
,
Jul 13 2017
Oh, that's great :) That must be Emulation.setEmulatedMedia: https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setEmulatedMedia
,
Jul 13 2017
cool , but unfortunately i have no idea how to use this option using chrome --headless , which is what i want to do? any idea?
,
Jul 13 2017
You'll have to use DevTools to issue this command. Run headless with --remote-debugging-port=9222 and connect to the websocket. See the blog post [1] for more info on how to use DevTools with headless. [1] https://developers.google.com/web/updates/2017/04/headless-chrome
,
Jul 13 2017
yeah i understood thanks, but problem is there are some cases where we can't open ports , so in that case ?
,
Jul 13 2017
Sorry, but you'll have to use the devtools protocol. I'm afraid we're not adding command line options for print options, as we previously discussed in bug 603559 .
,
Jul 13 2017
If that's not an option for you, you could consider embedding headless chrome in your application, see the readme for details about that [1]. [1] https://cs.chromium.org/chromium/src/headless/README.md?type=cs&q=headless/readme&sq=package:chromium&l=57
,
Jul 13 2017
yeah i read those comments ,:( unfortunately we have no way to use DevTools using command line options , any future hope for this ???
,
Jul 13 2017
okay let me check that
,
Jul 13 2017
thanks, i checked it thoroughly , well i am noob to chromium is there any documentation / tutorial available to compile/build this stuff ?
,
Jul 13 2017
For building, see chromium developer docs... http://www.chromium.org/developers/ There aren't any plans to add command line options to --headless for this. Our primary API provided to developers is DevTools, not the command line. See also bug 719921 .
,
Jul 13 2017
alright , thanks a lot all of you
,
Jul 13 2017
i built chromium successfully using following steps http://www.zackarychapple.guru/chrome/2016/08/24/chrome-headless.html any idea or tip how can i enable these DevTools only for this headless version ? Thanks
,
Jul 13 2017
https://developers.google.com/web/updates/2017/04/headless-chrome will get you started See the "Using programmatically (Node)" section. You'll likely use chrome-remote-interface. This will require some development and unfortunately we can't help you further as it's out of scope for us. Good luck!
,
Jul 14 2017
alright thanks :) |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by thestig@chromium.org
, Jul 11 2017