Open pubpub-zz opened 4 months ago
Thank you very much for looking into this so fast!
I see you already saw the next issue, I'm just adding more view points from my machine. The Matrix data does fix the orientation for the field we discussed. But as you noticed the text is mangled because of extra padding \x00 bytes and appears squished. Sadly the Matrix patch doesn't seem to fix all orientation errors, it is still messed up for some fields like this date in that same template. I went ahead and fresh installed from your 2731 patch (https://github.com/pubpub-zz/pypdf/tree/iss2731) and filled the template with this slightly adjusted code (it now also writes something into the date field "Tag-Monat 1" (don't be confused this one doesn't have an underscore like "Stellenbezeichnung_1" for some reason)).
New build code
from pypdf import PdfReader, PdfWriter
reader = PdfReader("template.pdf")
writer = PdfWriter()
writer.append(reader)
writer.update_page_form_field_values(
writer.pages[0],
{
"Stellenbezeichnung_1": "some filled in text",
"Tag-Monat 1": "03.07"
},
auto_regenerate=False
)
with open("filled-out.pdf", "wb") as output_stream:
writer.write(output_stream)
Now when I open this date field in some softwares it says theres a template that requires it to be in the format of "D D M M " notice the double space in the middle, I don't think orientation is related to that and I couldn't parse out anything about the pdf with PyPDF that would say thats needed but maybe it helps you.
I attached pictures from different viewers (evince, firefox, chromium) with the latest nightly version and with your even newer 2731 patch. Issue with the date happens in both versions.
evince: ![Screenshot_20240703_075937](https://github.com/py-pdf/pypdf/assets/174149262/a5812793-f9bf-4b5c-bf4a-55bd87bbc0b0) firefox (interestingly the date is oriented correctly here): ![Screenshot_20240703_075927](https://github.com/py-pdf/pypdf/assets/174149262/e2198816-0f5c-4375-9e6a-d80ef6b4b16b) chromium: ![Screenshot_20240703_080710](https://github.com/py-pdf/pypdf/assets/174149262/dc30f31c-659d-4c10-bc96-6babfd26e759)
evince: ![Screenshot_20240703_080816](https://github.com/py-pdf/pypdf/assets/174149262/b67d7aca-ea24-4ba8-8a79-116f35fc1c8e) firefox (again the orientations are correct here but you can see the \x00): ![Screenshot_20240703_080842](https://github.com/py-pdf/pypdf/assets/174149262/243b729b-4d0d-4a2c-a1f0-c41c90d46647) chromium: ![Screenshot_20240703_081126](https://github.com/py-pdf/pypdf/assets/174149262/8fc53a02-fab5-46ea-a4ae-e95e7fdfe5fa)
I also attached the documents generated on my machine. filled-out-nightly.pdf filled-out-2731patch.pdf
Thanks again, it feels like Adobe tailored the PDF specification to be a messy pain in the ass on purpose...
@orgmast5 created:
Originally posted by @pubpub-zz in https://github.com/py-pdf/pypdf/issues/2731#issuecomment-2204404945