cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
great1
Frequent Visitor

Print or Save Webpage to PDF

Hello

 

I have already built a solution using web recorder which takes me to a specific webpage. We need to print to PDF the webpage.

 

On the page there is a Print button which does this:

 

javascript:window.print()

 

The problem is the web recorder does not record anything I do within the standard Chrome print dialog box (e.g. selecting the destination as 'Save as PDF', or actually clicking the blue 'Save' button.

 

I do not want to screenshot the webpage for formatting reasons.

 

Also, I would need some advice as to how to handle the actual PDF i.e once the save button is clicked, how to programmatically choose a file name and folder to save it.

 

I do not mind if the solution is to use another browser (currently using Chrome).

 

Thank you

9 REPLIES 9
great1
Frequent Visitor

Hello everyone.

 

any help with this project would be much appreciated!

 

many thanks in advance

 

great1

Dudeonyx
New Member

Switch to the Desktop recorder after you get to the print dialog.

 

The print dialog isn't a webpage so the Web recorder won't work on it

By the moment I use this option with Chrome "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk-printing for resolve the problem, the flow is working.

yasunm02
Solution Sage
Solution Sage

1. 'Launch new Edge' with the page you want
2. 'Display select folder dialog' - select folder to save. %SelectedFolder% as variable produced
3. 'Display input dialog' - define file name to save. Define %File% as variable produced
4. 'Set variable' %FileName% = %SelectedFolder%\%File%
5. 'Get window', foreground window
6. 'Focus window', by instance = %AutomationWindow%
7. 'Send keys' {LControlKey}({P})
From here, use Desktop Recorder to get UI elements:
8. Select Save as PDF and click button 'Save'
9. In the 'Save as' window, select 'Name' field and populate it with %FileName%
10. Click 'Save'

Thanks a  lot, work in Chrome too.

OXDevUser
Regular Visitor

@yasunm02 / @rcardenasb: I'm always getting the error: "Failed to press button (button wasn't found)" in my Action 10.  Are you able to provide a step by step screencapture of how you were able to get it to work?

OXDevUser_0-1638851779841.png

 

1) I would use {LControlKey}(p) - Send Keys can read “P” as Shift+p.

2). I don’t think I have tried print to pdf and then had a save button, it’s usually a print button. If there is a save button, try send keys for control + s.

 

Hope this helps. 

VJR
Super User
Super User

Hi @OXDevUser 

 

- After pressing Ctrl P

- Give a wait stage for the print dialog to open

- Then sendkeys for Enter

This will hit the save button.

 

Here it is assumed that you already have set the destination to "Save as Pdf"

 

Etignor1
Helper II
Helper II

I know I'm late to the party but I just had this issue too.  What I did was to select Adobe DC as my default viewer to .png.  So I save webpage and it saves as png but when I open it, BOOM!  PDF

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (3,687)