From html to pdf

Hello friends,
@rkelchuri, @Ninett_Panfir, @Rammohan91, @balupad14, @Florent_Salendres, @vvaidya, @Palaniyappan, @ClaytonM, @vvaidya, @lakshman, @Dave,

If I give the HTML format then can UiPath convert HTML to PDF with proper font and css?
Thank you,
Cami

Yes. I think you can open the html in a browser then use “Print” to print to PDF. Or there might be a Save As PDF feature as well.

Other way would be to open the html in Word and use its feature to save as PDF. I’m assuming Word will open the html correctly, but I haven’t done that in a while.

Regards.

Thank you so much,

how to do that with word capabilities?
Cami

Hi @CamiCat,
The @ClaytonM idea is very good. Normal conversion sometimes is having some styles issue. But when you do direct print as a PDF. It is good.

Regards
Balamurugan.S

I saw some Extensions to print document. May be you can try.

https://chrome.google.com/webstore/detail/save-webpage-as-word-docu/mcebgdgbcbdkgdljffnkkbekldnidbmn?hl=en

Regards
Balamurugan.S

You can use Save As or Print. I think Print to PDF works well.
image

You can get there with alt+f+p
TypeInto "[k(alt)]fp"

The only problem is Word might not format your html correctly, but you can try it.

I think opening it in a browser would work better. You can use Open Application or Start Process to open Chrome or iexplore with the html filename as the argument. Then, use the Print

You can get to Print by doing ctrl+shift+P
Then, Select Item for the Print to PDF option

Regards.

1 Like

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