How to use permission value in PDF Compressor Command Line? -perms or -dPermissions parameter.

While testing the Pdf compressor command line
I want to use the parameter -permit
Where can I find the values for (int ) ?
e.g.: only display and printing is allowed !

Regards
Customer
-------------------------------------------------------------------------------
image
VeryDOC PDF Compressor Command Line Home Page,

https://www.verydoc.com/pdfcompressor.html
-------------------------------------------------------------------------------
Hello alls,

I need help to deal with permissions and passwords using pdfcompressor.exe application.

I don't exactly understand the meaning of "flag bit". The PDF Reference Manual use a "bit position" number from 1 to 32 to define the flags, but it's not the flag bit, which is a multiple of 4. What's the exact relation between the "bit position" of the PDFReference and the "flag bit" used by pdfcompressor.exe?

Is it meaningfull to use permission without using encryption? If not, does the OwnerPassword is enougth to restrict user permission?

Must I always add the -dEncrytpion argument or is there a default encryption method hard coded in pdfcompressor.exe?

Assuming I want to user of the pdf to may do everything except extract font embeded in the document, which command line should I use?

Assuming I want the user to may only print and preview, which command line should I use?

Assuming I want the user to may print, preview, add and modify annotations, which command line should I use?

Thanks a lot for your answers and for all your work!

Customer
-------------------------------------------------------------------------------
Read the Adobe PDF Reference, Third Edition, table 3.15 for full details of the user access permission values.

   4 = Print document (possibly not at the highest quality level).
   8 = Modify contents of document, except as controlled by 32, 256 and 1024.
  16 = Copy text and graphics from document other than that controlled by 512
  32 = Add or modify text annotations, fill in interactive form  fields, and
       if 256 is set, create or modify interactive form fields
256 = Fill in existing interacive form fields, even if 32 is clear
512 = Extract text and graphics (in support of accessibility to disabled
       users or for other purposes).
1024 = Assemble the document (insert, rotate, or delete pages and create
       bookmarks or thumbnail images), even when 16 is clear
2048 = Add or modify text annotations

To enable all, use -dPermissions=-4, then subtract permissions to disable.
To allow only viewing, dPermissions=-3904.

VeryPDF
-------------------------------------------------------------------------------
I believe you are setting inappropriate security permission values for the
effect you wish to achieve.  Taking the values you have set we must use twos
complement arithmetic to arrive at a hex representation (the permission flag is
bit oriented, so hex is easier to examine).

-260 = FFFFFEFC
-516 = FFFFFDFC
-1028= FFFFFBFC

The top 20 bits are always set to 1 (as per the spec, so we can ignore those.
Bits 1 and 2 (we start numbering at 1) are always 0 as per the spec, so we can
also ignore those.

Hex   Binary
EFC = 1110 1111 1100
DFC = 1101 1111 1100
BFC = 1011 1111 1100

In all cases the following bits are set:

3  - Allow printing, check bit 12 for high resolution printing
4  - Allow modifications not controlled by bits 6, 9, 11
5  - Allow copy/extraction not controlled by bit 10
6  - Modify annotations, form filling. Bit 4 set so allow interactive form
7  - reserved must be 1
8  - reserved must be 1
12 - Allow high resolution printing

When permissions are set to -260 we clear bit 9:

9  - Fill in existing form fields *even if bit 6 is clear*

Since bit 6 is *not* clear this has no effect, form filling is already permitted.

When permissions are set to -516 we clear bit 10:

10 - Extract text and graphics.

However, note that this covers operations not controlled by bit 5. What exactly
this means is unspecified.

When permissions are set to -1028 we clear bit 11:

11 - Assemble the document, even if bit 4 is clear.

Since bit 4 is *not* clear this has no effect, document assembly is already
permitted.

There are two content copying controls displayed in Acrobat, when bit 5 is
clear, but bit 10 is 1 the content copying field is disabled, but the content
copying for accesibility field is enabled.

So lets try using what *I* think you want. Firstly we need to clear bits 4 and
6. These can be overridden by bits 9 and 11, but if they are already set to
true, then 9 and 11 will be ignored.

We need:
Existing form fields : 1111 1111 1111 1111 1111 1110 1100 0100
= FFFFFEC4 = -316

Content access : 1111 1111 1111 1111 1111 1101 1100 0100
= FFFFFDC4 = -572

Document assembly : 1111 1111 1111 1111 1111 1011 1100 0100
= FFFFFBC4 = -1084

Testing here this seems to control the fields correctly, as expected.

VeryPDF
-------------------------------------------------------------------------------
   4 = Print document (possibly not at the highest quality level).
   8 = Modify contents of document, except as controlled by 32, 256 and 1024.
  16 = Copy text and graphics from document other than that controlled by 512
  32 = Add or modify text annotations, fill in interactive form fields, and if 256 is set, create or modify interactive form fields
256 = Fill in existing interacive form fields, even if 32 is clear
512 = Extract text and graphics (in support of accessibility to disabled users or for other purposes).
1024 = Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even when 16 is clear
2048 = Add or modify text annotations

To enable all, use -dPermissions=-4.
To disable everything apart from viewing, combine the following -4 (base) -4 (print) -8 (modify) -16 (copy) -32 (annotate) -256 (interactive fields) -512 (copy for disability access) -1024 (assemble) -2048 (high quality print), so -dPermisions=-3904

To disable everything apart from viewing and printing: -3904-(-2048-4)=-1852

So you can run following command line to compress PDF file and enable only high quality print to PDF file,

pdfcompressor.exe -owner 123 -user 456 -perms -1852 -keylen 64 test.pdf out.pdf
-------------------------------------------------------------------------------

That means to disable filling of interactive form fields we add -4 (base) to -
256 = -260. To disable Print and Copy we add -4 (base) to -4 (print) and -16
(Copy) i.e -4 -4 -16 = - -24. We have tested for most of the combinations and
are working fine.

Also from your response I see that granularity is not permitted. For example,
I want to allow all other kinds of modifications to the document
except "Document Assembly". That means bit 11 must be cleared and bit 4 must
not be cleared. In your response you have mentioned:
-------------------------------------------------------------------------------
Since bit 4 is *not* clear this has no effect, document assembly is already
permitted.
-------------------------------------------------------------------------------

4  - Allow modifications not controlled by bits 6, 9, 11
11 - Assemble the document, even if bit 4 is clear.
From the above I interpreted that what can be controlled by bit 11 is
independent of what can be controlled by bit 4. That means even if bit 4 is
not clear I should be able to control Document Assembly by setting/clearing
bit 11.

Similarly for Content accessibility.
5 - Copy or otherwise extract text and graphics from the document by
operations other than that controlled by bit 10 10 - Extract text and graphics
(in support of accessibility to disabled users or for other purposes).

Is this understanding correct or not?

While we are doing more tests on this your clarifications on the above would help.

VeryPDF

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

This entry was posted in PDF Compressor and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!