649
Views
13
Comments
[Html2PdfConverter] HtmlToPdfConverter setting font
Question
html2pdfconverter
Web icon
Forge asset 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.

What about Shift-JIS?
2012-10-08 11-59-27
Guilherme Pereira
Staff
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
UserImage.jpg
Mark Cowan
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.
2012-10-08 11-59-27
Guilherme Pereira
Staff
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

UserImage.jpg
Mark Cowan
Okay - I'll give that a try.

Thanks.
2016-04-21 20-09-55
J.
 
MVP

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

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


UserImage.jpg
Mark Cowan
@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



2012-10-08 11-59-27
Guilherme Pereira
Staff
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?

Cheers,
Guilherme




UserImage.jpg
Mark Cowan
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


2012-10-08 11-59-27
Guilherme Pereira
Staff
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
2023-05-16 02-25-49
Xiao Hui

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.

pdf-chinese.jpg
UserImage.jpg
Bruno Dâmaso

Hello

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


2018-03-26 21-02-10
Kit Lam

Bruno Dâmaso wrote:

Hello

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



I bumped into the same problem this week. There seems be to a problem if you try to use the same font on your PDF which is defined in your theme and shown on your screen. Let's check that by defining another font in the css of your PDF-screen like this:

If this is going to show your page and PDF in this 'Times New Roman" font, try to use your standard font in here. You will find out that it won't work.

2020-02-13 05-29-21
Anagha Chikate

Hello,
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.
TIA,
Anagha

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.