Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command Line Tool to Disable PDF Printing

Tags:

security

pdf

Does anyone know of a "FREE" command line tool that can lock a pdf from a user being able to print it. I need to be able to put this in a batch to loop through a folder and disable printing from adobe standard and reader. Is this possible to do it from command line with any tool?

like image 874
thedemon Avatar asked Aug 15 '12 18:08

thedemon


People also ask

How do I disable printing in PDF?

The "Permissions" setting controls restrictions that can be placed on the PDF file. To prevent printing of a PDF file, uncheck the "Allow the document to be printed" option. You must always enter a master password when security options are enabled or when a user password is set.

Can you make a PDF not printable?

If you have Adobe Professional, you can create non-printable pdfs by: Open your PDF document. Click on Document menu at the top of the page and select Security, then select “Show Security Settings for this Document.” A dialog box should open up, click on the Security tab.


2 Answers

First, pdftk:

You can use pdftk for (available for Linux, Unix, Mac OS X and Windows) to set an "owner password":

pdftk \
  input.pdf \
  output semi-protected.pdf \
  owner_pw "supersecret" 

Result is this, for example:

pdfinfo semi-protected.pdf | grep Encrypted:

  Encrypted:      yes (print:no copy:no change:no addNotes:no)

You can modify the command to additionally require a user password to open the PDF:

pdftk \
  input.pdf \
  output semi-semi-protected.pdf \
  owner_pw "supers3cr3t" \
  user_pw "s3cr3t"

You can modify the command to (selectively) "allow" other user actions:

pdftk \
  input.pdf \
  output semi-semi-protected.pdf \
  owner_pw "supers3cr3t" \
  allow ModifyContents \
  allow CopyContents \
  allow ScreenReaders \
  allow ModifyAnnotations

Result may be this, for example:

pdfinfo semi-semi-protected.pdf | grep Encrypted:

  Encrypted:      yes (print:no copy:yes change:yes addNotes:yes)

Second, podofoencrypt:

Commandline example:

podofoencrypt \
   --rc4v2 \
   -o "supers3cr3t" \
   -u "s3cr3t" \
   --edit \
   --copy \
   --editnotes \
   --fillandsign \
   --accessible \
   --assemble \
     input.pdf \
     semi-protected.pdf 

Big, fat caveat:

You should be aware, that this way of 'protecting' PDF files is by no means super-secure. There are quite a lot of PDF cracker software utilities out there which easily un-protect your PDF files. This method is only a very basic means to prevent most noobie computer users to mess with your files.


In addition, see also

Third, qpdf:

in Martin Schröder's answer!

like image 122
Kurt Pfeifle Avatar answered Oct 29 '22 10:10

Kurt Pfeifle


qpdf can do this:

qpdf                 \
  --encrypt          \
    "user-password"  \
    "owner-password" \
    40               \
  --print=n          \
  --                 \
    infilename       \
    outfilename

or even

qpdf                 \
  --encrypt          \
    "user-password"  \
    "owner-password" \
    128              \
  --print=non        \
  --accessiblity=y   \
  --force-V4         \
  --modify=form      \
  --                 \
    infilename       \
    outfilename
like image 33
Martin Schröder Avatar answered Oct 29 '22 10:10

Martin Schröder