Michael A Michael A - 3 years ago 153
Java Question

Reading encrypted pdf Metadata without decrypting the file

I am using iText to encrypt PDF files:


Notice I am specifying

But when I try only to read the Document Metadata like this (without decrypting the Document):

PdfReader ReadInputPDF = new PdfReader(path);
byte Document_MetaData[] = ReadInputPDF.getMetadata();

I get "Bad user password" exception.

Is there a way to read the metadate with out decrypting the document?

Answer Source

So, as mkl said the PdfWriter.DO_NOT_ENCRYPT_METADATA simply sets the MetaData which can be read as a clear text. Using Java i can simply use InputStream and read the file, searching for the metadata.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download