Save or Print Webpage as PDF

I have a csv file that contains lists of URLs.
I’m able to open this csv and step into each row and navigate to the lists URLs and open within a browser.
I need a mechanism by which I can save or print that Web Page into a PDF document.

I need to help with this save or print as PDF part. Please let me know how I can achieve this. Thanks a a lot in advance.

Once Robot opens a Page, Send Ctrl + P (print command) on Chrome, change to Save as PDF (More settings optionally according your needs)

2 Likes

Thanks, but how do I specify the file name for the pdf and which folder it should save. Thanks again for timely help.

Buddy @proshan its very simple,

Once you open the pdf kindly do the following to save your pdf and to the folder you need to save with

  1. Once pdf is opened use a send hotkey activity lie ctrl+p, while doing that itself before getting printed it will get saved first and again with keys “enter” to print it or if not we can pass a send hotkey activity again with keys ctrl+s
  2. Fine while saving the file if it asks for the folder to be saved, you can mention like
    "Folderpath" + “”+“Filename” + “.pdf” by using click and type into activity and pass that as input to the save field buddy
  3. Thats all buddy you are done

Kindly try this and let know buddy whether this works or not

Cheers @proshan

When I try to send enter key to the window I’m getting an error message “Value does not fall within the expected range”. In the Selector Editor I’m see app as “acrord32.exe” which is for Acrobat Reader I believe. Here is the full string

Here is the full exception that I’m getting

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.AggregateException: One or more errors occurred. ----> System.ArgumentException: Value does not fall within the expected range.
at UiPath.UiBrowserClass.get_node()
at UiPath.Core.Browser.get_Element()
at UiPath.Core.Activities.Target.<>c__DisplayClass35_0.b__0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
— End of inner ExceptionDetail stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at UiPath.Core.Activities.Target.GetBaseElement(ActivityContext context, CancellationToken token)
at UiPath.Core.Activities.Target.GetFindMethod(TargetFindCriteria criteria, CancellationToken ct, Int32 defaultTimeout)
at UiPath.Core.Activities.Target.GetElementAsync(TargetFindCriteria criteria, CancellationToken ct, Nullable1 delayBefore) at UiPath.Core.Activities.TargetAsyncActivity.GetElementAsync(AsyncCodeActivityContext context, CancellationToken ct, Nullable1 delayBefore)
at UiPath.Core.Activities.Click.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
at UiPath.Core.Activities.TaskAsyncCodeActivity.ExecuteAsyncWithResult(AsyncCodeActivityContext context, CancellationToken cancellationToken)
at UiPath.Core.Activities.TaskAsyncCodeActivity`1.BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, Object state)
at System.Activities.AsyncCodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

@proshan,

I can understand your problem. I hope you’re getting an error while sending hotkeys (ctrl+p) on the Acrord32.exe. Can you please check you’re a selector of SendHotkeys please use * for unique reference for a selector.

Thanks,
Arunachalam.

The error is not happening when sending the ctrl+p and it opens the print dialog as expected, the exception occurs when I send the ‘enter’ key to accept and close the print dialog. I also tried Click Button activity to press the OK button instead of sending Hotkey ‘enter’ and I get same error there as well.

Buddy great,
Buddy you were actually going good with enter key, the thing is it didn’t get to the right field that would get triggered when we press enter, so use a tab until it reaches the enter field and then use again send hotkey with enter key

That was the reason for error value doesn’t fall within the range, try buddy that would work and kindly let know whether this works or not

Cheers @proshan

I’ve tried that and that didn’t work either. Besides since OK is the default button it is able to trigger it no matter where my cursor is when I tried it manually. I’ve also tried giving some delay time to make sure it waits few seconds in the print dialog window before sending enter key

Did that work buddy @proshan

No it is still not working, If you don’t mind can I share my screen in Skype so you can take a look at it, when you have time. Thanks

1 Like

I think it’s simple

  • Robot Opens a Page (wait it’s loaded)
  • Send Ctrl + P Hotkey over Browser window, Change option to Save as PDF in Print Dialog (Attach it or Interact with Keyboard inside) and other settings if needed.
  • Attach Save as Window, Type PDF Path and (Send Enter, Click Save, Send Alt+S, etc.)
  • Continue other steps

No worries buddy kindly share your xaml buddy, that would help us a lot to do the best…
Cheers @proshan

I tried using the Recording feature to create the activities and that is working fine. Thanks all for your help

1 Like

@asesor-rpa I opened Chrome and navigated to the url I want to print to pdf. For this I did exactly what you said, viz, send hotkey CTRL+P. But strange that system opened this Capture

When I manually hit CTRL+P on Chrome, I see what is displayed by other users in this post(sorry, I can’t post two images in one post because I am a new user on UiPath community :D)

What is the difference in UiPath sending CTRL+P and I do it manually on the exact same page and same browser

In my current Chrome window when I hit Ctrl + P appears the Chrome Print Dialog in a separate window. When I hit Ctrl + Shift + P appears classic window print dialog window. I’m not sure about situation where same hotkey shows different UI. Try updating Chrome or Use Firefox to see if there’s a bug with Chrome

Ahh, I understood now. When you send ctrl+p(small letter), it opens Chrome’s print window and if you send ctrl+P(caps), it shows classic print window.

Thank you @asesor-rpa for your help

Can we do this entire process in the back-end ?

  1. Attach window with the selector of full screen (don’t try to find or put the selector of print pop up window). It will look something like
2 :- Send hotkey "Ctrl+P"

3 :- Click on “More Settings”. The selector will look like


“#####” => Title of the web page
4. Send hotkey “enter”