Wkhtmltopdf and Chinese characters

Trying to create a PDF file using wkhtmltopdf, but it gives me a lot of problems with displaying all characters.

Some of the characters work - for example. when printing

  • "Invoice No. (付款 编号)" The Chinese character No. 1, 2 and 4 is correctly printed, but the character No. 3 simply displays the empty space in PDF format.
  • "Customer number (客户 编号)" The Chinese character No. 1 and 4 are displayed correctly, but the characters No. 2 and 3 are not displayed in the PDF file.
  • "Total (总额)" none of the Chinese characters are displayed in the generated PDF file.

I am on a Ubuntu 14.04 desktop with wkhtmltopdf version "wkhtmltopdf 0.12.1 (with qt fixed)". I installed Chinese fonts and all the characters are displayed correctly in both gedit and Firefox on my system, but wkhtmltopdf only displays about 75%.

My HTML document is made using the UTF-8 character set and displays correctly in Firefox and gedit. I also tried to embed the font directly in the header style section using the tag

  src: url (data: font / ttf; base64, AAEA ....) 
, and wkhtmltopdf changes the font as expected, but the missing characters are still missing.

Any help is really much appreciated as I get ideas.

+5
source share
2 answers

Have you installed the Chinese, Japanese, and Korean fonts that are mentioned in the Ubuntu Community Wiki Help ?

+3
source

Having examined the PDF file in detail, you can find out which font is used in wkhtmltopdf. Dalibor Nasevich performed work for a large set of Asian fonts and described what he had to install on a CentOS (RedHat) -based system:

Finding out the missing fonts for wkHTMLtoPDF

According to Dalibror Nasevich, in a headless system based on the Debian banner, I had to add fonts-droid-fallback , fonts-wqy-microhei and f onts-wqy-zenhei

0
source

Source: https://habr.com/ru/post/1202533/


All Articles