Closed LeiYangGH closed 1 year ago
Hi @LeiYangGH,
PyHanko most certainly supports Chinese text, but the fact that it doesn't work "automagically" without extra config is a limitation of the file format. PDF is very particular about the way it manages fonts, and the "simple" fonts that we can assume are supported by all viewers only deal with Latin text.
To use Chinese in signature appearances, you'll need to supply an OpenType font (and install pyHanko with the [opentype]
optional dependency group). PyHanko will then embed a subset of the font into the document for you. Here's an example from the test suite with some Japanese text: https://github.com/MatthiasValvekens/pyHanko/blob/1e714718a16de04b01a7e69afc3451f7803a3b60/pyhanko_tests/test_stamp.py#L211-L232
EDIT: Sorry, I forgot you were a command-line user. In that case, have a look at this part of the docs to set up a style that uses an OpenType font of your choice: https://pyhanko.readthedocs.io/en/latest/cli-guide/config.html#style-definitions.
output.pdf Describe the bug My pfx file contains non-ascii(chinese) characters, and using following command to generate:
pyhanko sign addsig --no-strict-syntax --field 1/100,100,200,200/NAME pkcs12 input.pdf output.pdf secrets.pfx
the output file is attached.Expected behavior The signature appearance contains the signature's name.
Screenshots The signature appearance contains some strange characters.
Environment (please complete the following information):