0

I want to know if a PDF document uploaded to my applet is encrypted. Being an applet I don't want to have the whole of PDFBox (which does this) with my applet so I'm looking for something smaller or the code for doing this directly!

I am trying to go through the code for PDFBox to strip out just the necessary code but not sure if this is WAY too much work or even if it violates the licence.

1

1 Answer 1

0

Ok, looks like I was a better-off looking for the format of a PDF document than for any library:

FYI: PDFs have an ending called a "trailer" which goes something like this:

trailer
<< /Size 196 /Root 65 0 R /Encrypt 195 0 R /Info 1 0 R /ID [ > <5daebb80fcf4c7d4329e8cf5043af186> <5daebb80fcf4c7d4329e8cf5043af186> ] >>
startxref
300552
%%EOF

If encrypt is there, the document is encrypted (no reference for this but that's how PDFBox handles it and stands up to a few tests on encrypted and not encrypted PDFs.

This is a good basic introduction:

http://resources.infosecinstitute.com/pdf-file-format-basic-structure/

For the full spec look here

http://www.adobe.com/devnet/pdf/pdf_reference.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.