BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

export PDF with chinese

Open mattwang6868 opened this issue 4 months ago • 2 comments

Attempted Debugging

  • [x] I have read the debugging page

Searched GitHub Issues

  • [x] I have searched GitHub for the issue.

Describe the Scenario

This method it's works for me.

I choose using PHP-based default PDF rendering system "dompdf" I found a utility at dompdf github page It can convert TTF font files into font libraries for use with dompdf. step 1. Download utils to /bookstack/vendor/dompdf/

step 2. modify two lines in /utils/load_font.php


require_once "/bookstack/vendor/autoload.php"; $fontDir = "path to your chinese ttf file";


step 3. run "php load_font.php 'font name what you want' path to your chinese ttf file"

step 4. It will generate an installed-fonts.json file in the /bookstack/storage/fonts directory, which will include the font name.

step 5. Go to “Custom HTML Head Content” customization setting and add chinese fonts name.

body, h1 { --font-body: ......, "noto sans tc"; }

step 6. refresh browser and export pdf.

Exact BookStack Version

v25.05.2

Log Content


Hosting Environment

php-8.2.29 almalinux8.10 bookstack v25.05.2

mattwang6868 avatar Aug 22 '25 09:08 mattwang6868

@mattwang6868

I followed the steps to make the changes, but it didn't work. Is there any key point I might have missed?

php load_font.php DouyinSansBold DouyinSansBold.ttf

Image

body, button, input, select, label, textarea { --font-body: 'DouyinSansBold', 'Noto Serif', serif; --font-heading: 'Roboto', sans-serif; --font-code: 'Source Code Pro', monospace; }

http://zhangnianqiang.top/books/8bf12/page/hp-smart-tank-510-series-e3

zhang-nianqiang avatar Nov 14 '25 07:11 zhang-nianqiang

I think I missed some step after step 4....

Check the "fonts name" in "installed-fonts.json", it should be like this { "noto sans tc": { "normal": "/var/www/bookstack_file/bookstack/storage/fonts/NotoSansTC-Regular", "bold": "/var/www/bookstack_file/bookstack/storage/fonts/NotoSansTC-Regular", "italic": "/var/www/bookstack_file/bookstack/storage/fonts/NotoSansTC-Regular", "bold_italic": "/var/www/bookstack_file/bookstack/storage/fonts/NotoSansTC-Regular" } }

Add the fonts name what you see in json file to the customize CSS section.

mattwang6868 avatar Nov 18 '25 09:11 mattwang6868