Closed andi-dev closed 1 year ago
We ran into a couple of HexaPDF::Error, which we can live with, as we can at least rescue and fall back to not flattening the forms. (are you interested in these errors anyway?)
Yes, please, always :grin: They might indicate an invalid PDF or something that HexaPDF doesn't handle correctly. Either way there might be a way to gracefully handle the situations leading to the errors.
As for the NoMethodError
: I will have to test this out but I think an empty string should be valid, displaying nothing.
Here is an quasi-official comment on how appearance characteristics dictionaries (/MK
entry in widget annotation) are to be treated: https://github.com/pdf-association/pdf-issues/issues/56#issuecomment-797856300 - i.e. it is processor dependent.
Another comment here https://github.com/pdf-association/pdf-issues/issues/23#issuecomment-764216521
So, following the information from the linked comments and from the fact that if there is no marker character defined, HexaPDF will now draw no marker when an empty /CA
entry in the appearance characteristics dictionary is found. Change is live in the devel branch.
Sorry, too fast... :-/ I forgot to add the /NeedAppearances
entry in the main form dictionary so Acrobat just showed me what HexaPDF did instead of showing what it will do... Empty marker style string is the same as no marker style string, i.e. default marker for the field type. Commit adjusted and pushed to devel.
Now it is finished :grin:
Thanks again for the quick fix :) I just tried it with all 3 pdfs that previously ran into this error, and everything looks good now!
Hi Thomas,
we've been checking the
acro_form.validate
andacro_form.flatten
for a bunch of actual client pdfs.We ran into a couple of
HexaPDF::Error
, which we can live with, as we can at least rescue and fall back to not flattening the forms. (are you interested in these errors anyway?)But we also ran into one
NoMethodError
(backtrace below).I had a look into the code and in https://github.com/gettalong/hexapdf/blob/master/lib/hexapdf/type/acro_form/appearance_generator.rb#LL374C32-L374C32 this line you're - I think - trying to decode the check-mark character, falling back to
"4"
if non is specified?However we found 3 pdfs where
@widget[:MK]&.[](:CA)
is an empty string, thus@widget[:MK]&.[](:CA) || '4'
evaluates to""
.If I change the code to:
things seem to work out fine.
Backtrace