gettalong / hexapdf

Versatile PDF creation and manipulation for Ruby
https://hexapdf.gettalong.org
Other
1.21k stars 69 forks source link

text alignment lost when flattening acro_form #221

Closed andi-dev closed 1 year ago

andi-dev commented 1 year ago

Hi again 😄,

in the following pdf the text-alignment of form-fields get lost when flattening the form.

Original PDF:

image

Resulting PDF:

image

Screenshot from Acrobat:

image

Again, I am not sure how feasible it even is to adapt the various settings of form fields to the copied / created appearances when flattening the form, but I would be curious about your opinion / knowledge.

Thank you a lot in advance, and again: let me know if the original pdf would be helpful.

gettalong commented 1 year ago

I'm sorry but apart from the background color I don't really see any difference between these two screenshots. Generally, though, text alignment in form fields is supported, see https://hexapdf.gettalong.org/documentation/reference/api/HexaPDF/Type/AcroForm/VariableTextField.html#method-i-text_alignment and e.g. https://github.com/gettalong/hexapdf/blob/master/lib/hexapdf/type/acro_form/appearance_generator.rb#L409-L413.

So if it is not working in this case, there might be a bug in the implementation or alignment was done differently, in which case having the PDF in question would be very useful.

gettalong commented 1 year ago

@andi-dev I need your feedback to resolve this - thanks!

andi-dev commented 1 year ago

Hey Thomas,

I am really sorry! tThis was either not working with a previous version of hexapdf, or - more likely! - with a previous version of my code. And I didn"t even properly check the screenshot again before uploading them here 🙈