Closed andi-dev closed 1 year ago
Thanks for the detailed analysis and yes, you are completely right, the error lies on line 522 of the page.rb
file. The method would need to return annotations.to_ary
, though, not just annotations
because that might be HexaPDF::PDFArray
and not a simple Array.
I have fixed the error and the change is live on the devel branch if you want to try it out.
Thank you for the quick fix! I can confirm that the issue is solved :)
Hi again :)
I hope I am not getting it wrong, but when flattening the form hexapdf goes through the pdf page by page and has each page attempt to flatten the widget-annotations: https://github.com/gettalong/hexapdf/blob/master/lib/hexapdf/type/acro_form/form.rb#L397
the remaining annotations are being reassigned to the
not_flattened
variable.However in this line,
Page#flatten_annotations
returns an empty array when the page has nokey?(:Annots)
https://github.com/gettalong/hexapdf/blob/master/lib/hexapdf/type/page.rb#L522If I am not understanding it wrong, this means that once the iteration in
Form#flatten
hits a page without:Annots
it returns an empty array, thus essentially stopping the process of flattening the widgets. In consequence the further implementation ofForm#flatten
will remove the entire form without having actually flattened all the widgets.My test case is a pdf with 4 pages, where only the second page is containing any Annotations, namely for two
SignatureFields
. Running the current implementation ofacro_form.flatten
removes the signature fields entirely. When I change the https://github.com/gettalong/hexapdf/blob/master/lib/hexapdf/type/page.rb#L522 to fromreturn [] unless key?(:Annots)
toreturn annotations unless key?(:Annots)
the appearance of the signature fields remains visible.What do you think? Let me know if I can help you to clarify any further.