cancel
Showing results for 
Search instead for 
Did you mean: 

Print a webpage into a pdf file

ToshinobuNakam1
Level 2

When a virtual worker interacts with Print wizard on a webpage, the only viable option for interaction appears to be UI Automation mode.

15301.png

However, since it takes 10-15 seconds for each interaction (i.e, read, select, and click), it amounts to be more than 1 minutes to print a webpage into a PDF file.
Is there any better way to do it in order to reduce the processing time? 



------------------------------
Toshinobu Nakamura
------------------------------
1 BEST ANSWER

Helpful Answers

PabloSarabia
Level 11
Hi @ToshinobuNakam1

Interesting topic I guess, we always need to think in the best way to get a good perform of our processes.

I try several approach to solve this...

- Installing an extension in the browser that perform this. I found this one: Foxit PDF Creator. But I have not been able to get it to work 😞
- Getting the page with an external command using Google Chrome. This is possible, but only for MacOS and Linux, I didn't found anything for Windows
- And the last one... using code.

Exists a lot of external libreries to get this, but a lot of this have pay subscription. The best of all that I try is IronPDF

But I don't know why, when I use it in Blue Prism environment, the final PDF is watermarked 😞

15293.png
The "no watermarked" version is created by using Visual Studio.

The only way that I see this possible is creating an external Exe file (I can help you with this if you need something), then give to this Exe file the webpage that you want to convert into PDF and call it from Blue Prism.

The code for this is very simple

First you need to download the IronPDF.dll and import it over the Blue Prism folder. Then add the reference in the Initialise page.

And this is the code:

var Renderer = new IronPdf.ChromePdfRenderer();
using (var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format"))
       PDF.SaveAs(@".\wikipedia.pdf");




Hope this helps you!

See you in the Community, bye 🙂










------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------

View answer in original post

5 REPLIES 5

PabloSarabia
Level 11
Hi @ToshinobuNakam1

Interesting topic I guess, we always need to think in the best way to get a good perform of our processes.

I try several approach to solve this...

- Installing an extension in the browser that perform this. I found this one: Foxit PDF Creator. But I have not been able to get it to work 😞
- Getting the page with an external command using Google Chrome. This is possible, but only for MacOS and Linux, I didn't found anything for Windows
- And the last one... using code.

Exists a lot of external libreries to get this, but a lot of this have pay subscription. The best of all that I try is IronPDF

But I don't know why, when I use it in Blue Prism environment, the final PDF is watermarked 😞

15293.png
The "no watermarked" version is created by using Visual Studio.

The only way that I see this possible is creating an external Exe file (I can help you with this if you need something), then give to this Exe file the webpage that you want to convert into PDF and call it from Blue Prism.

The code for this is very simple

First you need to download the IronPDF.dll and import it over the Blue Prism folder. Then add the reference in the Initialise page.

And this is the code:

var Renderer = new IronPdf.ChromePdfRenderer();
using (var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format"))
       PDF.SaveAs(@".\wikipedia.pdf");




Hope this helps you!

See you in the Community, bye 🙂










------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------

diane.sanzone
Level 7
Hi Toshinobu,

Have you tried creating a separate object that attaches only to the print to PDF window?  I've found that if my only option to interact with a window is UIA, chances are it's a spawned window and re-attaching directly to it allows me to use more traditional methods of interaction.  Alternatively, my team has had success using the Kofax PDF Create add in or even full Adobe (which can be very expensive), but again, for those we used unique objects for the interactions.

Hope this helps and good luck!

------------------------------
Diane Sanzone
------------------------------

Thanks for sharing your knowledge, Pablo. The approach 1 & 3 didn't work out for me, but approach 2 was able to successfully print a webpage to a pdf file! 
This is the website that I referred to.

<https://superuser.com/questions/592974/how-to-print-to-save-as-pdf-from-a-command-line-with-chrome-or-chromium>

But, in my case, it was not possible to directly print from a webpage to a pdf. (Some special characters in the URL got in the way and the command prompt threw an error) So, I save a webpage as html file first, then turn it into a pdf file using approach 2.

Anyway, thank you for sharing your thoughts on this! Without it, I couldn't discover this solution. 



------------------------------
Toshinobu Nakamura
------------------------------

Thank you for your answer, Diane! I built a separate object for Print window, but the speed of processing was not fast enough to satisfy the requirements. Anyway, I really appreciate your kindness to share your thoughts on this issue!

------------------------------
Toshinobu Nakamura
------------------------------

Hi Toshi,

Kindly share the object for Print window, it will really helps to us. Thanks in advance!!

------------------------------
Jagadeesh Nandibakthula
------------------------------