0

I need to export form data from a PDF file without user interaction. In a few words, the client will upload the filled form, then I need to read the data, correct it, fill out some other fields and put it back into the form. I have no control on the file (it's a government survey), and because of encryption I can't iterate through it programmatically.

The file has a couple of buttons on it, one of which exports the data to an XFDF file. So I'm wondering if there is anyway way to call that button's click from Java or even Javascript.

Thanks

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
chris
  • 649
  • 7
  • 26
  • 1
    *government survey* - is it publicly available? In that case please supply a link. Furthermore please indicate your PDF library of choice. – mkl Feb 03 '15 at 05:18
  • There's a class `FdfWriter` in iText to which you can pass a `PdfReader` that reads a PDF file, looping over all the fields in the AcroForm, creating an FDF file in the process. This isn't the same as "executing the script of a button", but the end result is an FDF file with the fields and the data of the original form. – Bruno Lowagie Feb 03 '15 at 08:18
  • @mkl - unfortunately it's confidential. I'm open to any open-source library, but for the moment I'm using PDFbox. – chris Feb 03 '15 at 08:54
  • @BrunoLowagie - Does that work with encrypted files too? – chris Feb 03 '15 at 08:56
  • It depends how they are encrypted: with a certificate? No. With a user password? Not if you don't have the password? With an owner password? Yes, even without that password. Note that iText is free, open source software, but that doesn't mean that you can use if *for free* in all cases. There is a strong *copyleft* license attached to iText. – Bruno Lowagie Feb 03 '15 at 08:57
  • @chris *unfortunately it's confidential* - ok. If you can provide an equivalent example, that would do, too. Otherwise it's difficult to help. – mkl Feb 03 '15 at 09:26
  • @BrunoLowagie - this is all I know: http://oi57.tinypic.com/95wynr.jpg – chris Feb 03 '15 at 10:11
  • 1
    So you can open and view it without providing a user password? In that case, there is only an owner password. See the question [How to read PDFs created with an unknown random owner password?](http://stackoverflow.com/questions/15955620/) to find out how to access such a PDF. You can also find this question in the free ebook [The Best iText Questions on StackOverflow](http://pages.itextpdf.com/ebook-stackoverflow-questions.html). – Bruno Lowagie Feb 03 '15 at 10:34
  • @BrunoLowagie - Thanks Bruno :) I love the variable's name! – chris Feb 03 '15 at 13:52

0 Answers0