Re: [chromium-dev] How to delay print to PDF

276 views
Skip to first unread message

Lei Zhang

unread,
Jul 27, 2017, 1:54:44 AM7/27/17
to ofer...@gmail.com, headless-dev
+headless-dev
-chromium-dev

On Wed, Jul 26, 2017 at 10:45 PM, עופר בר <ofer...@gmail.com> wrote:
> Hi,
>
> I am using headless chromium on Windows 10 (Version 62.0.3166.0 (Developer
> Build) (64-bit)) to print a web application report running on Tomcat/Java
> server and angular 2 client into a PDF file (product in development)
>
> If I'm using this:
>
> chrome --headless --disable-gpu --print-to-pdf=my.pdf https://angular.io
>
> I get a the PDF result just fine.
>
> But when running locally to the Tomcat/Java server:
>
> chrome --headless --disable-gpu --print-to-pdf=my.pdf
> http://localhost/report/1
>
> I get an empty PDF file (no content).
>
> My guess is that the specific report page takes longer to render, as it has
> to make few REST calls to the server to build the report.
>
> My question: is there any way to add a delay in Chromium before printing to
> PDF?
>
> I also tried to run nodeJS wrapper code such as: simple-headless-chrome, but
> it uses Chrome and not Chromium, so it's not good for me.
>
> Any idea would be greatly welcome!
>
> Thx
>
> Ofer
>
> --
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "Chromium-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/301a08fa-76c8-45a5-930e-54574650ec05%40chromium.org.

dvallet (Chromium)

unread,
Jul 27, 2017, 2:54:47 AM7/27/17
to Lei Zhang, ofer...@gmail.com, headless-dev
Headless chrome should wait until the page is loaded before printing to PDF, but yeah maybe the REST calls are triggered after the load event is fired.

Try saving a screenshot with --screenshot=screen.png and see what it draws, if it's blank also then you are on the right track. 

For NodeJS, I believe you can pass the executable path to simple-headless-chrome so that it uses your binary. Then you can just wait until all the loading is done





--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev...@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/CACSHbcTB1ASMDP%3DtLeYWe-zOUZLNtSAdb_dHtVsyLmquFLNhZA%40mail.gmail.com.

עופר בר

unread,
Jul 27, 2017, 5:14:49 AM7/27/17
to headless-dev, the...@chromium.org, ofer...@gmail.com
screenshot also shows a blank page.

Thanks for your reply!

suraj0...@gmail.com

unread,
Oct 23, 2017, 5:40:22 AM10/23/17
to headless-dev, ofer...@gmail.com, the...@chromium.org
I am having same problem.
Any one found solution without nodeJs?
Reply all
Reply to author
Forward
0 new messages