-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Forms: appearance generation broken for autosized fields, fields with center alignment and unicode text #1919
Comments
@brzGatsu. |
Sure, in this pdf you can observe all 3 problems:
|
covers autosize from py-pdf#1919
the autosize has been fixed in PR #2002 |
Hi there, just want to let you know that a fix would still be still relevant for us - we are still stuck with PDFtk. |
As always, you are of course invited to further analyze this and propose a corresponding PR to fix this. |
Hi @pubpub-zz, I just tried again and was happy to see that unicode text is now supported. That leaves us with only one thing left: the alignment issue. I investigated a bit and saw, that when reading the fields (by iterating page.annotations) those that should have center alignment, have the "Q" flag set to 1. The pdf standard says Q stands for quadding (justification) and 1 is for centered. So it seems that the field is read correctly. However, when writing, this information seems to get lost and everything is left-aligned. The text is only centered while the field has keyboard focus. |
Could you please provide proper code and the corresponding PDF file(s) in question? I have not been able to find any code in this issue. |
Hi, you can find an example PDF a few comments further up but I attached it again since pypdf threw some error with it. There is really not much to show in code, I basically copied the pypdf documentation on writing forms:
The zero in the "Basis" column of output.pdf should be centered |
With regards to form fields with the writer.set_need_appearances_writer(True) This doesn't resolve the alignment issue (which appears to be a miswriting of the PDF as described here: #1919 (comment)), but it does appear to fix the auto-sizing issue |
Hi @pubpub-zz, absolutely appreciate your effort in fixing py-pdfs form capabilities. I tested 3.11.1 and replaced pdftk with pypdf in our app. Its already looking quite good but there are still some appearance generation issues:
Tested with current Acrobat Reader and Sumatra, happens on both.
Relates to:
#1306
#355
The text was updated successfully, but these errors were encountered: