私は次のように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>
OPTIONS は次のようになります:
-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 ビットのキーの長さは短すぎると思います。より長いキーを使用することをお勧めします。