Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to convert files to pdf using the libreoffice command line tool like this -

libreoffice --headless --convert-to pdf filename

Now I want to restrict the printing, editing and converting of the converted file, how do i achieve that on the command line.

share|improve this question

1 Answer 1

Just use a command line tool like pdftk or the PDFbox java library to postprocess the pdf.

Here's an example to encrypt the file 1.pdf using pdftk, allowing the user to print the file (from the pdftk Server examples):

pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz allow printing

The Apache PDFBox library comes with some command line tools. Here's an example how to encrypt a file using PDFBox on the command line:

java -jar pdfbox-app-x.y.z.jar Encrypt [OPTIONS] <password> <inputfile>

where OPTIONS may be:

-O                           The owner password to the PDF, ignored if -certFile is specified.
-U                           The user password to the PDF, ignored if -certFile is specified.
-certFile                    Path to X.509 cert file.
-canAssemble                 true   Set the assemble permission.
-canExtractContent           true   Set the extraction permission.
-canExtractForAccessibility  true   Set the extraction permission.
-canFillInForm               true   Set the fill in form permission.
-canModify                   true   Set the modify permission.
-canModifyAnnotations        true   Set the modify annots permission.
-canPrint                    true   Set the print permission.
-canPrintDegraded            true   Set the print degraded permission.
-keyLength                   40     The number of bits for the encryption key.
inputfile                    The PDF file to encrypt.   
outputfile                   The file to save the encrypted document to. If left blank then it will be the same as the input file.

NB: a key lenght of 40 bits would IMHO be too short - using a longer key is recommendable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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