export PDF with chinese #5407

Open
opened 2026-02-05 10:02:34 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @mattwang6868 on GitHub (Aug 22, 2025).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • 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

Originally created by @mattwang6868 on GitHub (Aug 22, 2025). ### 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](https://github.com/dompdf/utils) 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 ```text ``` ### Hosting Environment php-8.2.29 almalinux8.10 bookstack v25.05.2
OVERLORD added the 🐕 Support label 2026-02-05 10:02:34 +03:00
Author
Owner

@zhang-nianqiang commented on GitHub (Nov 14, 2025):

@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 commented on GitHub (Nov 14, 2025): @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 <img width="1456" height="354" alt="Image" src="https://github.com/user-attachments/assets/fb337dea-c0dd-4863-888f-78fed320edbb" /> 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
Author
Owner

@mattwang6868 commented on GitHub (Nov 18, 2025):

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.

<style> body, h1 { font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Oxygen, Ubuntu, Roboto, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif, **noto sans tc**; --font-code: Lucida Console, DejaVu Sans Mono, Ubuntu Mono, Monaco, monospace, **noto sans tc**; } </style>
@mattwang6868 commented on GitHub (Nov 18, 2025): 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. <style> body, h1 { font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Oxygen, Ubuntu, Roboto, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif, **noto sans tc**; --font-code: Lucida Console, DejaVu Sans Mono, Ubuntu Mono, Monaco, monospace, **noto sans tc**; } </style>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5407