-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing and unknown text in outline when use pdf.start_section()
#458
Comments
Thank you for reporting this. This may be related to #365 & #459 |
Not really in my opinion, since this is the pdf outline which doesn't use custom font to render. |
I have a starting point for a fix, in from binascii import hexlify
import codecs
class PDFString(str):
def serialize(self):
# Using the "Hexadecimal String" format defined in the PDF spec:
return '<%s>' % hexlify(codecs.BOM_UTF16_BE + self.encode('utf-16-be')).decode('latin-1') With this new string serialization logic, @hackinteach's code generates PDFs that display a readable outline in Adobe Acrobat reader. What's even more frustrating is that if I pass the resulting PDF file to the
But I can't figure exactly what kind of "clean-up" Any help would be appreciated 😊 |
Sounds like you'd have to compare the binary data in the two files. |
As |
I submitted #463 that should fix this |
Ah yes, in hindsight it makes sense that UTF-16 strings would need a BOM. |
The fix as been merged in the Note that you can install the latest unreleased version of
|
Error details
I used
pdf.start_section()
with Thai language and the generated outlines are missing characters and some have extra junk characters. I tried put these words in random order and the error persist with the words.The problematic words are as follow:
I noticed that there are some words in the junk text that actually used in the outline such as
สีผม, ระดับฮอร์โมนเพศชาย, ความไวต่อการเจ็บปวด
.However, when I try to write minimal code to reproduce the error, the same words as above were disappeared from the outline and the first outline section is incomplete (try code below).
Minimal code
Please download Kanit font to see the Thai characters got rendered.
Environment
fpdf2
version used: 2.5.5The text was updated successfully, but these errors were encountered: