Hi All,

Just reposting my previous question in a clearer way in the hope that some 
friendly person has a solution...

I'm trying to fill in XFA values and encrypt a PDF containing an XFA form. From 
reading Paulo's replies when encryption questions pop up, I know the encryption 
needs to be done as soon as the stamper is created. so the code I'm using looks 
like:

...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(passedPdfReader, baos);
stamper.setEncryption(PdfWriter.ENCRYPTION_AES_128, "", "", 
PdfWriter.ALLOW_PRINTING);

XfaForm xfaForm = stamper.getAcroFields().getXfa();
xfaForm.fillXfaForm(passedInputSource);

stamper.setFullCompression();
stamper.close();
return baos.toByteArray();
...

However, this doesn't do what I'd expect. It ignores all the filled XFA values 
leaving blank fields in the final PDF. I've tried all 4 of the various
similar setEncryption() methods on PdfStamper, but they all do the same thing -
they cause the filled XFA data values to not appear in the final PDF.

If setEncryption() is removed, the final PDF is filled in ok, but unsecured. If 
setEncryption() (in any of the 4 similar variants) is enabled, the final PDF is 
secured, but with no XFA data filled in.

I've also tried using stamper.getWriter().setEncryption(byte[], byte[], int,
int), using null byte arrays rather than empty strings for the passwords. But
that also had the same problem.

The passwords are left null/empty so that iText uses its random password 
generation - because we don't need to unsecure the final PDF, and we'd prefer 
not to have any record of the passwords.

The variant of setEncryption() which takes a Certificate array hasn't been
tried, since I don't have any public certificates to use.

Has anyone got any suggestions to encrypt an XFA PDF without losing all the 
added form data?

Thanks for your help,
Adam Carless

The contents of this message and any attachments are confidential and are
intended for the use of the persons to whom it is addressed.
If you are not the intended recipient, you should not copy, forward, use or
alter the message in any way, nor disclose its contents to any other person.
Please notify the sender immediately and delete the e-mail from your system,
if you so wish you can contact us on +44 1624 688000. The sender is not
responsible for any alterations that may have occurred without authorisation.
Any files attached to this email will have been checked by us with virus
detection software before transmission. You should carry out your own virus
checks before opening any attachments, as we do not accept any liability for
loss or damage which may be caused by viruses.

For information regarding company registration please visit the contact page at 
www.hansard.com

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to