I’m trying to generate a Table of Contents (TOC) in a PDF using wkhtmltopdf (version 0.12.6). I want the header text for the TOC to display non-English characters, like Japanese characters. However, when I pass Japanese text such as "目次" to the --toc-header-text argument, it gets truncated and only displays the English part. Here’s my simplified command:
wkhtmltopdf --encoding "UTF-8" toc --toc-header-text "目次" --xsl-style-sheet toc-style.xsl input.html output.pdf
I also used meta charset in XSL but still did not worked:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I also cannot predefine it as simple text in the HTML file because the text value in --toc-header-text is multilingual and needs to be passed dynamically at runtime
I’m trying to generate a Table of Contents (TOC) in a PDF using wkhtmltopdf (version 0.12.6). I want the header text for the TOC to display non-English characters, like Japanese characters. However, when I pass Japanese text such as "目次" to the --toc-header-text argument, it gets truncated and only displays the English part. Here’s my simplified command:
wkhtmltopdf --encoding "UTF-8" toc --toc-header-text "目次" --xsl-style-sheet toc-style.xsl input.html output.pdf
I also used meta charset in XSL but still did not worked:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I also cannot predefine it as simple text in the HTML file because the text value in --toc-header-text is multilingual and needs to be passed dynamically at runtime
Share Improve this question edited 2 days ago user5005768Himadree asked Feb 18 at 4:33 user5005768Himadreeuser5005768Himadree 1,4373 gold badges30 silver badges65 bronze badges 1- My Example can display multi language(stackoverflow/questions/73568996/…) – life888888 Commented 2 days ago
1 Answer
Reset to default 0Based on my experience using WKHTML for generating a UTF-8 PDF, I have some suggestions that might work:
--title
works better than--toc-header-text
for handling non-English text- Try Without
--toc-header-text
. i.e. set this in HTML file<h1>目次</h1>
and modify your command like so:wkhtmltopdf --encoding "UTF-8" toc input.html output.pdf
- Check your font, it might not support Japanese characters.
Cheers.