pypdf icon indicating copy to clipboard operation
pypdf copied to clipboard

Forms: appearance generation broken for autosized fields, fields with center alignment and unicode text

Open brzGatsu opened this issue 1 year ago • 5 comments

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:

  • Text is always aligned left, even if the field is set to i.e. center (unless you click in the field)
  • Fields with font size set to auto are not showing at all (unless you click in the field)
  • Unicode characters such as the german Ü are not encoded properly (looking correct when clicking into the field). Not sure if it helps, but in our current code we create the fdf with this (and then hand it to pdftk) and have no encoding issues: https://github.com/ccnmtl/fdfgen/tree/master/fdfgen

Tested with current Acrobat Reader and Sumatra, happens on both.

Relates to: https://github.com/py-pdf/pypdf/issues/1306 https://github.com/py-pdf/pypdf/issues/355

brzGatsu avatar Jun 26 '23 15:06 brzGatsu

@brzGatsu. When you are clicking on the fields the viewer is generating the appearance. this is why results looks good that way. Can you provide some PDFs for point 1 and 2.

pubpub-zz avatar Jun 28 '23 19:06 pubpub-zz

Sure, in this pdf you can observe all 3 problems:

  1. All the numbers should be center aligned
  2. The "Talente" column is set to auto font size, check the "Talente" cell in the row "Gebräuche" - its content only shows when clicking in the field.
  3. Same Row - the text Gebräuche is malformed. pypdf_forms_bug.pdf

brzGatsu avatar Jul 04 '23 20:07 brzGatsu

the autosize has been fixed in PR #2002

pubpub-zz avatar Jul 22 '23 16:07 pubpub-zz