Hi Carl,
pdf-reader is a low-level library, and other than text extraction it
doesn't have a "porcelain" API for detecting features like encryption.
Still, it does provide a way to walk the PDF internal structure and
detect most features. In this case, every read-only PDF uses
Encryption, which is indicated by the 'Encrypt" key in the document
trailer:
pdf = PDF::Reader.new("my-file.pdf")
pdf.objects.trailer.key?(:Encrypt)
If the Encrypt key exists, then you can fetch the "P" param to see
what features are enabled/disabled:
pdf.objects.trailer.fetch(:Encrypt).fetch(:P)
The P value is an int where each bit position indicates a feature.
There's a table in section 7.6.3.2 of the spec [1] that describes each
bit.
James
[1]
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
> --
> You received this message because you are subscribed to the Google Groups
> "PDF::Reader" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
pdf-reader+...@googlegroups.com.
> To post to this group, send email to
pdf-r...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/pdf-reader.
> For more options, visit
https://groups.google.com/d/optout.