wkhtml2pdf footer-html/header-html 参数的编码问题
Encoding issue with wkhtml2pdf footer-html/header-html parameters
我正在使用 utf-8 编码从 HTML 文件生成 PDF。事实上,我的一些标题包含 non-ascii 个字符。在主 PDF 中,一切正常,编码正确,渲染正常。
设置我的 footer.html 文件时,我检索当前部分,只要部分名称中有 non-ascii 字符,该部分就不会正确显示。
此部分名称作为 "section" URL 参数传递给 footer.html 调用;它的编码已经是错误的。例如,我在我的 xsl 文件中将目录标题更改为法语 "Table des matières"(这是对默认 xsl 所做的唯一更改)。
目录页面在 PDF 中很好,“è”是正确的。但是在我的页脚中,我通过 JS 检索 URI,它给我 before unencoding : mati%C3%A8res
(当我期望它是 mati%E8res
时),这当然显示在我的 PDF 页脚为 matières
我在模板、主 html 文件或 header/footer html 文件中发现了许多关于编码问题的页面,其中 none 与这些参数有关。我怎样才能使它在 PDF 中正确?
示例 运行:
F:\test>wkhtmltopdf.exe --encoding "UTF-8" --footer-html footer.html \
--print-media-type toc --xsl-style-sheet default.xsl test.html test.pdf
Loading pages (1/6)
Counting pages (2/6)
Loading TOC (3/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
问题出在我的 JS 代码上。在参数上我使用 unencode()
而不是使用正确的函数 decodeURIcomponent()
我正在使用 utf-8 编码从 HTML 文件生成 PDF。事实上,我的一些标题包含 non-ascii 个字符。在主 PDF 中,一切正常,编码正确,渲染正常。
设置我的 footer.html 文件时,我检索当前部分,只要部分名称中有 non-ascii 字符,该部分就不会正确显示。 此部分名称作为 "section" URL 参数传递给 footer.html 调用;它的编码已经是错误的。例如,我在我的 xsl 文件中将目录标题更改为法语 "Table des matières"(这是对默认 xsl 所做的唯一更改)。
目录页面在 PDF 中很好,“è”是正确的。但是在我的页脚中,我通过 JS 检索 URI,它给我 before unencoding : mati%C3%A8res
(当我期望它是 mati%E8res
时),这当然显示在我的 PDF 页脚为 matières
我在模板、主 html 文件或 header/footer html 文件中发现了许多关于编码问题的页面,其中 none 与这些参数有关。我怎样才能使它在 PDF 中正确?
示例 运行:
F:\test>wkhtmltopdf.exe --encoding "UTF-8" --footer-html footer.html \
--print-media-type toc --xsl-style-sheet default.xsl test.html test.pdf
Loading pages (1/6)
Counting pages (2/6)
Loading TOC (3/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
问题出在我的 JS 代码上。在参数上我使用 unencode()
而不是使用正确的函数 decodeURIcomponent()