限制libreoffice命令列工具轉換的pdf文件的列印、編輯和轉換

限制libreoffice命令列工具轉換的pdf文件的列印、編輯和轉換

我正在嘗試使用 libreoffice 命令列工具將文件轉換為 pdf,如下所示 -

libreoffice --headless --convert-to pdf filename

現在我想限制轉換後的文件的列印、編輯和轉換,如何在命令列上實現這一點。

答案1

只需使用一個命令列工具,如 pdftk 或 PDFbox java 庫對 pdf 進行後處理。

1.pdf這是使用加密檔案的範例pdftk,允許使用者列印文件(從pdftk 伺服器範例):

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

Apache PDFBox 庫附帶一些命令列工具。這是一個範例,說明如何在命令列上使用 PDFBox 加密文件:

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

其中選項可能是:

-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.

注意:恕我直言,40 位元的金鑰長度會太短 - 建議使用更長的金鑰。

相關內容