[Html2PdfConverter] HtmlToPdfConverter setting font
Forge component by Miguel 'Kelter' Antunes
Published on 02 Jun 2020
Is it possible to set the font for the downloaded PDF file?

I assume UTF-8 is supported. But it doesn't seem to be the default.

What about Shift-JIS?
Rank: #3
Hi Mark,

The component is a wrapper to the library wkhtmltopdf so you may want to check on their site what is supported and how to set any special options.

In the options there's one that allow you to set the enconding so you may want to test that one.

 --encoding <encoding>           Set the default text encoding, for input
As for the fonts you should create your pages and use any font available (or import additional) because the component itself all it does is to render your page in HTML and export it to pdf.

Hope this helps

Rank: #3
Hi Mark,

The OtherArgs parameter passes anything as command line parameters and generically is --XXXXX YYYYY.

I recommend you to install wkhtmltopdf directly on your pc and test via command line until you nail it and then pass the same arguments when using the component.


Rank: #13

it's possible, but you have to include the fonts yourself.

on that note, italics/bold fonts are somewhat trickier.

Rank: #3564

I was able to install 
wkhtmltopdf locally and I was able the make a pdf of locally installed webpage using the option

wkhtmltopdf --encoding UTF-8 C:\path\to\index.html C:\path\to\file\location\myIndex.pdf

Just make sure <meta charset="UTF-8" /> is set in the header of index.html

But - still doesn't work in my application.

I'll keep trying and post here when I'm successful.

I'm passing the URL info to HtmlToPdfConverter like so

And pass the --encoding UTF-8 option like this

Rank: #3
Hi Mark,

I suggest you try to render the same page you're on the server instead of a local copy because like that you'll try to replicate what happens in the server.

something like: wkhtmltopdf --encoding UTF-8 https://path_to_my_page C:\path\to\file\location\myIndex.pdf.

If you do it like this does it work?


Rank: #3564
Good morning,

I wasn't able to get see any of my pages on the OutSystems cloud. I suspect passwords are needed.

But I was able to make a good pdf file of my company's homepage. That website uses Shift_JIS encoding.

So, the problem is not with wkhtmltopdf; it's with my pages.

Outsystem automatically puts this header tag into all pages.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
So it's a puzzle.
And I'm about to be pulled off this project (such is the wizdom of project managers). So, we don't need to put any more effort into this.
Thank you very much for all your help.

Rank: #3
Hi Mark,

You need to set your pages as anonymous in order for it to work. The request done by tge component is from a webkit headless browser and does not share the session with your own browser as such a new login would be necessary and as you don't have control over the execution for example to input a username and password in said execution you need to set tge page anonymous and use other kinds of protection (e.g a generated token on the url).

if you do return to the project feel free go reach out to us again and we'll do our best to assist you.

Rank: #2451


I have a similar problem which I my page contains chinese characters. When the page print to PDF, the chinese characters shows square shape. 

This is convert to PDF:

The font can be seen in the webpage: 

I tried to set "--encoding UTF-8" in OtherArgs also doesn't work.

Anyone successfully to encode chinese character in html2pdf?



Rank: #18036


I have the same problem, I need to use the font 'Titillium'.
when I create the screen that is the "face" of .pdf it looks good, but when I download it I lose the fonts, how can I make the .pdf also have the same font?

thank you

Rank: #2485

Did anyone found solution to this?
i am also running into same problem where I want t o use some other font, but its not happening when I download the pdf.