Try [ctrl]+[shift]+p instead of [ctrl]+p. A quicker and easier approach to your pdf printer.
If the pdf printer is your default printer all you have to do is bash print and enter the filename + path
You can use the UiPath.PDF.Activities package, which provides activities for working with PDF files. This package includes the “Convert HTML to PDF” activity that allows you to convert HTML content to a PDF file. This activity works on both Windows and non-Windows platforms.
This is a switch which converts HTML to PDF using Chrome in the background.
While there is a switch which enables us to directly download webpages as PDF, if the webpage in question requires authentication then we can’t convert it to PDF. It will retrieve and convert the login page to PDF instead - which is not what we want.
Also, we can’t pass headers so that is a bummer as well, so the workaround I employed was to create an HTML template, store it in Storage Bucket and pass it into the workflow as an in Argument which consisted of the header and footer with a placeholder for the DOM content.
The bot would navigate to each page, fetch the required sections of the DOM using either Find Children(Classic) or Get Attribute(Modern), replace it with the placeholder present in the HTML template and use the Chrome Command Switch to convert HTML to PDF:
There’s a bit more to it(maintaining CSS folder) but the approach is robust, works super fast with a 100% accuracy rate.
I hope you find this resourceful and that it will help you out one day!
Dim filePath As String = in_htmlFile
Dim url As String = “file:///” & System.Uri.EscapeUriString(filePath.Replace(“”, “/”))
Console.WriteLine(url)
'Set the chrome.exe file path
Dim chromePath As String = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”
If Not File.Exists(chromePath) Then
Dim userFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
chromePath = userFolder+“\AppData\Local\Google\Chrome\Application\chrome.exe”
End If
If Not File.Exists(chromePath) Then
Throw New Exception(“Unable to locate Chrome.exe”)
End If
Console.WriteLine(“saving”)
Using p As New Process()
p.StartInfo.FileName = chromePath
p.StartInfo.Arguments = “–headless --disable-gpu " &
“–run-all-compositor-stages-before-draw --print-to-pdf=””" & in_pdfFilePath & “”" “”" & url & “”“”
p.Start()
p.WaitForExit()
End Using