Get PDF document Restriction Summary

Started by Integra, November 01, 2010, 05:18:54 AM

Previous topic - Next topic

Integra

I am using EXIFTOOL to get Document Properties (General & Restriction summary) of a PDF.

I have read the Exif help document and found the way to get the General Document properties like Author, title, created date, creator. Is it possible to get the document restriction summary properties like commenting, printing, etc... The main thing is, I want to find the comment is enabled in this document or not and I dont want to change them? (I have attached the screen shot of my requirement)

Thanks in advance!

Phil Harvey

This feature was added last week with exiftool 8.35.  The information you want is extracted as the UserAccess tag.

- Phil

P.S.  Gotta love it when a feature is added before it is requested. :)
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Integra

Thanks for the quick reply.
      I saw the updated document and I tried the below code in the command line. (Actually, I am not clear of using "UserAccess" tag)

exiftool -UserAccess "myPDFPath"

but i did not get anything, so please help me how to find the comment is enabled/disabled in the PDF.

Phil Harvey

If you got nothing, it is likely because the PDF document is not encrypted.  In this case, I believe you should have full access.

Here is an example output run on a number of files:

> exiftool ../pics -ext pdf -pdfversion -encryption -useraccess
======== ../pics/a.pdf
PDF Version                     : 1.3
======== ../pics/asndevdatasheet.pdf
PDF Version                     : 1.5
======== ../pics/compress.pdf
PDF Version                     : 1.3
======== ../pics/cs4.pdf
PDF Version                     : 1.5
======== ../pics/embedded_jpg.pdf
PDF Version                     : 1.4
======== ../pics/encrypt-a.pdf
PDF Version                     : 1.7
Encryption                      : Standard V1.2
User Access                     : Fill forms, Extract, Assemble, Print high-res
======== ../pics/encrypt-b.pdf
PDF Version                     : 1.7
Encryption                      : Standard V1.2
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Assemble, Print high-res
======== ../pics/encrypt-c.pdf
PDF Version                     : 1.7
Encryption                      : Standard V2.3
User Access                     : Extract
======== ../pics/encrypt-d.pdf
PDF Version                     : 1.7
Encryption                      : Standard V2.3
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Print high-res
======== ../pics/encrypt-e.pdf
PDF Version                     : 1.7
Encryption                      : Standard V2.3
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Print high-res
======== ../pics/encrypt-f.pdf
PDF Version                     : 1.7
Encryption                      : Standard V4.4
User Access                     : Extract
======== ../pics/encrypt-g.pdf
PDF Version                     : 1.7
Encryption                      : Standard V4.4
User Access                     : Extract
======== ../pics/encrypt-h.pdf
PDF Version                     : 1.7
Encryption                      : Standard V4.4
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Print high-res
======== ../pics/encrypt1.2_ExifTool.pdf
PDF Version                     : 1.3
Encryption                      : Standard V1.2
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Assemble, Print high-res
======== ../pics/encrypt1.2_no_password.pdf
PDF Version                     : 1.3
Encryption                      : Standard V1.2
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Assemble, Print high-res
======== ../pics/encrypt2.3_ExifTool.pdf
PDF Version                     : 1.4
Encryption                      : Standard V2.3
User Access                     : Modify, Annotate, Fill forms, Assemble
======== ../pics/encrypt2_certificate.pdf
PDF Version                     : 1.6
Encryption                      : Adobe.PubSec V2 (adbe.pkcs7.s4)
======== ../pics/encrypt4.4-open_ExifTool.pdf
PDF Version                     : 1.7
Encryption                      : Standard V4.4
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Print high-res
======== ../pics/encrypt4_certificate.pdf
PDF Version                     : 1.6
Encryption                      : Adobe.PubSec V4 (adbe.pkcs7.s5)
======== ../pics/encrypt5.5-open_ExifTool.pdf
PDF Version                     : 1.7
Encryption                      : Standard V5.5
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Print high-res
======== ../pics/encrypt5.5.pdf
PDF Version                     : 1.7
Encryption                      : Standard V5.5
User Access                     : Extract
======== ../pics/encrypt5.5_ExifTool_noencryptmeta.pdf
PDF Version                     : 1.7
Encryption                      : Standard V4.4
User Access                     : Extract
======== ../pics/encrypt5.5_password.pdf
PDF Version                     : 1.7
Encryption                      : Standard V5.5
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Print high-res
======== ../pics/encrypt5_certificate.pdf
PDF Version                     : 1.6
Encryption                      : Adobe.PubSec V5 (adbe.pkcs7.s5)
======== ../pics/encrypt_password.pdf
PDF Version                     : 1.7
Encryption                      : Standard V5.5
User Access                     : Print, Modify, Copy, Annotate, Fill forms, Extract, Print high-res
======== ../pics/openoffice_hex_string.pdf
PDF Version                     : 1.4
======== ../pics/osx10.6.pdf
PDF Version                     : 1.3
======== ../pics/pdf-x.pdf
PDF Version                     : 1.3
======== ../pics/testing20c.pdf
PDF Version                     : 1.5
    1 directories scanned
   29 image files read


You should be able to add comments to a PDF document if it is not encrypted, or if the Annotate flag is set in the UserAccess.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Integra

Thanks Phil,
   Your reply is very much useful. I tried it for the encrypted PDF and its working.

Actually my requirement is, I need to check a PDF whether it is "Enable for Commenting in Adobe Reader". This can be retrieved from Document Restrictions Summary.

But Exiftool provides details from "document which is only encrypted". I want the Enable Comment property which is irrelevant on the Encryption of PDF.

I can set the comment enable property in acrobat professional (manually). And I save that PDF. After saving I open it in reader. In that I can make comments in the PDF documents.
If I am not setting the enable comments property in the professional then I can't make comments in the reader. So actually I want this information for my PDF document.

I have attached image with this post specifying the requirement.

Phil Harvey

Thanks for explaining this.  I have a trial version of Acrobat Pro at home so I will run some tests tonight to see if I can extract the information you want.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

#6
I'm running Acrobat Pro right now, and as far as I can tell the "Document Restrictions Summary" just reflects your  current access rights.  They may be different (as in your PNG image) if either the new security settings haven't been saved, or if your have entered an owner or user password to enable these privileges.  I have found no way to disallow commenting in the Document Restrictions Summary without encrypting the document with some sort of protection (like password protection).  Of course, the password may be empty to allow anyone to open it, but still, that's the only way I see to enable any restrictions, and I believe this is what ExifTool is reporting under UserAccess.

But if I am wrong I would like to know how to enable document restrictions without encryption.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Integra

Thanks for the Reply Phil,

   I have attached the png file describing how to enable comment in Acrobat reader using Acrobat Pro.
1. set the property in Acrobat Pro and save it.
2. then open the document in reader. (then only you can find the difference.)

Phil Harvey

Thanks again.  I have managed to create a document with these extra permissions.  Wow.  PDF permissions are really complex, but I should be able to extract the information you want.  I'll post back here when I have more details.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

#9
These annotation permissions are associated with a digital signature.  I can now extract the following additional information from the sample I created:

Signing Date                    : 2010:11:03 06:32:40-04:00
Signing Authority               : ARE Acrobat Product v8.0 P23 0002337
Annotation Usage Rights         : Create, Delete, Modify, Copy, Import, Export


I hope this gives you what you want.  This new ability will appear in ExifTool 8.38 when it is released (probably in a few days or so).

There are other digital signature types which may also be used, and I decode information for these as well.  You will need to check the UserAccess, AnnotationUsageRights and/or ModificationPermissions tags depending on the encryption and/or digital signature technique used.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Integra

Thanks for the Reply Phil,
   I am eagerly waiting for the new version of the tool

hbuehler

Hi Phil,

you are doing an incredible job, thank you for all your effort.
When I've encountered your Exiftool that could show us the setting of the PDF restriction property "Page Extraction" I was excited.
But unfortunately it does not work with the documents we process.

We used the following syntax:
exiftool . -ext pdf -pdfversion -encryption -useraccess -annotationusagerights -modificationpermissions

But only received the following output:
======== ./Test1.pdf
PDF Version                     : 1.7
======== ./Test2.pdf
PDF Version                     : 1.7
    1 directories scanned
    2 image files read

When looking up the security properties in the two PDFs, the "Extract Page"-property is "not allowed"
May it be possible to send one of these documents to you to have a look?

Yours
Heinrich

Phil Harvey

Hi Heinrich,

Sure.  Email a sample to me (philharvey66 at gmail.com) and I'll take a look.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

#13
Heinrich, I got the document you sent, thanks.

This document is signed, but not encrypted.  I re-read the PDF 1.7 specification, but it still isn't clear to me what permissions are implied by a signed document.  However, the one thing I did note is that the permissions are different if the signature is valid.  Unfortunately, validating a signature isn't something that I plan to do in ExifTool because it would add significantly to the processing time.

Having said this, and assuming that the signature is valid, I still don't understand how to determine the permissions of a signed document.  I need to spend a bit more time looking into this.

- Phil

Edit: fixed typo
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

hbuehler

Dear Phil, thanks a lot!

It is incredible to see that you can determine the permissions of an encrypted document but that the handling in case of an unencrypted is so different.
What reason may be behind of this from Adobe's point of view to make all so difficult?

Seeing forward to hearing from you

Heinrich