-
Notifications
You must be signed in to change notification settings - Fork 25
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
Most unicode characters added with write_fillable_pdf() disappear when flattening PDF #48
Comments
Hey I was having some printing issues on iOS regarding some of this, have you tried mypdf.flattenpdf(file_name, outfile_name, as_images=True) the as_images optional converts the pdf to an image and back into a pdf and this fixed the printing issue I was having and it might help your issue as well! |
Oddly enough, that's the version that does NOT work for me. I have three versions of the code set up:
The special symbols appear correctly in versions 1 and 2, but do NOT appear in version 3. |
Interesting, have you tried just reinstalling poppler-utils which is needed for the 3rd version to work correctly? Could be an issue with the CL dependency. For my issue your second version of flattening was causing an issue where text would not print correctly when being printed from an iOS device. |
I can try, but the poppler flattening seems to be working in general, and even shows special characters so long as they're ones that appear in section D2 of the PDF manual. It only fails for other unicode characters. Could I trouble you to try these symbols on your system to see if as_images flattens them correctly? |
You are going to have to use the as_image method to make it work I had the same issue but using the poppler method resolved it.. Just make sure poppler is installed properly or send me your error log i can check for you..
|
figured this might be worth adding for any future people coming here with this problem: i spent ages trying to fix this exact issue, and @EthanC-8's method didn't work... only to discover that the typeface being used to fill the pdfs was not compatible with certain special characters. when looking at the pdfs before they were flattened, i realized that the special characters were changed to a default typeface that was compatible with those characters. then, when flattening the pdf, those default-font characters would disappear. so... don't be me. before assuming it's an issue with the library or your code, make sure the typeface actually includes those special characters, lol |
Characters that are represented in section D2 of PDF manual version 1.7 (starting on page 1001) work fine.
However, other unicode characters such as ■ (U+25A0) disappear when I flatten the page. These unicode characters do appear if I leave the PDF un-flattened. Flattening the PDF, however, causes them to disappear.
I've tried flattening the PDF in two separate ways:
In 1, special characters appear
In 2, special characters do NOT appear.
Although option 2 is generally "better" in terms of rendering text consistently and correctly sized, it fails to render special characters.
Basically if the pdfrw.PdfString.to_bytes() value looks like "(\x81)" it will flatten correctly. However, if the pdfrw.PdfString.to_bytes() looks like "" it will vanish during the flattening process.
EDIT: My question originally implied that 1 and 2 both failed to show special characters. In fact, it only fails when using flatten_pdf(as_image=True)
The text was updated successfully, but these errors were encountered: