# [Html2PdfConverter] HtmlToPdfConverter setting font

Forge Component

### Html2PdfConverter

(49)
Published on 21 Mar by Guilherme Pereira
Published on 21 Mar by Guilherme Pereira
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.

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

Guilherme
With the Execute Action, what is the systax for the expression used by OtherArgs?

I've tried "--encoding UTF-8", but the characters are unreadable.

And "encoding=UTF-8" corrupts the file.
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.

Cheers,
Guilherme

Okay - I'll give that a try.

Thanks.

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

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

@Guilherme

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

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 http://path_to_my_page C:\path\to\file\location\myIndex.pdf.

If you do it like this does it work?

Cheers,
Guilherme

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.

Mark

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.

Cheers,
Guilherme

Hi,

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?

Thanks.