automatically download PDF

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

automatically download PDF

Postby waterblast » Fri Oct 09, 2020 2:04 pm

Is there any possible way to automatically download a PDF opened by a website instead of using the built-in PDF viewer?

I need to save the PDF with a manually given name, instead of the .PDF name

I'm using WinForms visual studio 2019.

I really dont know where to start, any help would be loveley :D

Friendly regards.
waterblast
Newbie
 
Posts: 3
Joined: Fri Oct 09, 2020 2:01 pm

Re: automatically download PDF

Postby magreenblatt » Fri Oct 09, 2020 2:21 pm

If you run with the "--disable-pdf-extension" command-line flag then loading a PDF file will trigger a download and show the Save As dialog.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: automatically download PDF

Postby waterblast » Fri Oct 09, 2020 5:42 pm

magreenblatt wrote:If you run with the "--disable-pdf-extension" command-line flag then loading a PDF file will trigger a download and show the Save As dialog.


That's great to hear!

Is there any possible way to automate the process of downloading the file? Instead of showing the Save As Dialog?
waterblast
Newbie
 
Posts: 3
Joined: Fri Oct 09, 2020 2:01 pm

Re: automatically download PDF

Postby magreenblatt » Fri Oct 09, 2020 5:49 pm

You can implement CefDownloadHandler.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: automatically download PDF

Postby waterblast » Mon Oct 12, 2020 3:56 pm

magreenblatt wrote:You can implement CefDownloadHandler.


Topic can be closed, i've got it!

Thanks for the fast and clear reply!
waterblast
Newbie
 
Posts: 3
Joined: Fri Oct 09, 2020 2:01 pm

Re: automatically download PDF

Postby misop » Mon Apr 11, 2022 6:04 am

We use "--disable-pdf-extension" for opening a PDF files in system default PDF viewer (silently download PDF to temp and then open in Adobe Reader). Everything works great. Now we need to print website with Print Preview ("--enable-print-preview") and we found, that Print Preview doesn't work with "--disable-pdf-extension". With "--disable-pdf-extension" appears only standard windows print dialog.

cefclient with "--enable-print-preview --disable-pdf-extension" works the same.

We found issue about modify response, that can resolve problem with PDF handling: https://bitbucket.org/chromiumembedded/cef/issues/2785 but it is not closed.

Is there any possible way to automatically download a PDF instead of using the built-in PDF viewer and keep Print preview working?

Thank you!
misop
Newbie
 
Posts: 1
Joined: Mon Apr 11, 2022 4:28 am

Re: automatically download PDF

Postby magreenblatt » Mon Apr 11, 2022 10:59 am

Print preview requires the PDF viewer. Issue 2785 that you linked looks like the best solution for you.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 87 guests

cron