0

I have a password protected document (not allowing the printing) and I want to Digitally sign it. When opening the file with iText I have BadPasswordException.

I read in the book that iText needs the password to manipulate the document so I gave the PDFReader constructor the password and I have this exception:

java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V

It seems that the metadata is encrypted too.

My questions:

Is there a way to digitally sign the document without the password? Signing is allowed

The document is not created from iText so how to bypass the metadata encryption?(DO_NOT_ENCRYPT_METADATA)

Thanks Jamil

Jamil Nour
  • 41
  • 4
  • `java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V` - that sounds like you have an older java xml API implementation together with a newer java xml API in your class path. Please clean up the jars you use. – mkl Jun 05 '17 at 14:21
  • AbstractMethodError solved by removing xerces library from classpath: https://stackoverflow.com/questions/23831030/pdfstamper-fails-on-several-pdf-files-itext-5-5-1 – Jamil Nour Jun 06 '17 at 11:01

2 Answers2

0

As per this post https://forums.adobe.com/thread/1661225 it is impossible to digitally sign a secured document except if a blank digital signature fields are presented.

I was trying to add a digital signature without a blank digital signature field which it seems impossible

Any confirmation from iText?

Jamil

Jamil Nour
  • 41
  • 4
  • If the document is currently only protected by password encryption, not also by another signature, you can remove the protection and then sign (and protect again if you want). If you don't want to remove the original protection, the answers on the Adobe forum are correct, though. – mkl Jun 06 '17 at 14:26
  • Is it possible to protect a signed document? The protection will not affect the digital signature? – Jamil Nour Jun 06 '17 at 15:37
  • You have to sign and protect simultaneously. – mkl Jun 06 '17 at 20:19
  • What do you mean by simultaneously? Any hint – Jamil Nour Jun 07 '17 at 21:02
  • *What do you mean by simultaneously?* - The same `PdfStamper` that signs shall also (re-)introduce a password protection. – mkl Jun 07 '17 at 22:04
  • Please change your answer to reflect the working solution. – mkl Jun 11 '17 at 21:58
0

The following post How can I lock a PDF document after signing it? has the solution and how to proceed. I applied it and it is working.

My case is different because after the first digital sign of the protected document I want to sign it again in different area and by different certificate depends of a workflow. As mkl confirmed the Adobe answer it is not possible

The locked document signed once:

enter image description here

The locked document signed twice:

enter image description here

Jamil Nour
  • 41
  • 4