Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fill out an Acroform or XFA? #44

Open
jesseshieh opened this issue Aug 14, 2018 · 6 comments
Open

How to fill out an Acroform or XFA? #44

jesseshieh opened this issue Aug 14, 2018 · 6 comments

Comments

@jesseshieh
Copy link

Hi, First off, thanks for an awesome library! I was reading through the docs and examples, but I couldn't figure out if it's possible to fill out an XFA or Acroform using Origami. I figured out how to extract XFA data from a pdf, but I'm still not sure how to fill one out. Can you point me in the right direction? Thanks!

@rgerard
Copy link

rgerard commented Dec 17, 2018

+1. I'd also like to know the answer to this question.

@untoldone
Copy link

untoldone commented Jun 27, 2019

Been poking around here comparing PDFs with forms filled vs PDFs without forms filled using pdfwalker.

If you do something like this you'll find you'll fill a field

pdf = Origami::PDF.read "input.pdf"
puts pdf.fields[0].T # Field Name
pdf.fields[0].V = "hello world"
pdf.write "output.pdf"

Though the problem I'm having is that when I write the pdf like this, mac preview appears visually to have not have the field filled in until i click on the field at which point the text is visible. When I used an online tool as an alternative to convert the PDF to a JPG the fields do show up...

I suspect another part of the PDF needs to be modified at the same time but I was also poking around other libraries which don't seem to make other changes when form filling? (though maybe theres another calculation that happens on save?) ... anyways I'll keep investigating this or eventually give up and switch to something PDFTK based.

@untoldone
Copy link

untoldone commented Jun 27, 2019

Adding a bit more ... super weird behavior -- If I manually set the form text content via Mac Preview + save and open the file -- I find the content in pdf.fields[0].V. If I then change it using setV save and open the file with preview again, the old content is still in the field ... except when I click on the field the new content shows up. I tried this with forms generated by Acrobat as well as as forms generated by open office.

@gdelugre Perhaps this is a bug? I really don't know enough about PDF to know if this is behaving as expected or if it is something else. I noticed you tagged this as both feature and question -- does that mean form filling isn't currently supported?

@danielricecodes
Copy link

I'm finding that the above snipped doesn't appear to work. When I write out the file after setting a Value via the V= setter, the file can't be opened. I am not 100% sure this library can fill in PDF fields?

fuel_—_-bash_—_204×56

I'm personally looking for a pure ruby implementation of something like PDFTK or FillablePDF because both of those require a lot of memory. In FillablePDF's case, it requires Java.

@rngtng
Copy link

rngtng commented Aug 24, 2020

any updates here? I've same issue and happy for any pointers.. thx

@democlitos
Copy link

First read this post.

Now basically after chanding the 'V' value you also need to change the AppearanceStream, and Origami does that automatically to you when you set:

pdf.Catalog.AcroForm.NeedAppearances=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants