问题
A password protected pdf file can be generated with ghostscript:
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=protect.pdf -sOwnerPassword=pwd1 -sUserPassword=pwd2 -dCompatibilityLevel=2.0 test.pdf
The output file has the newest pdf version 2.0 which has unicode support for password protection. But according to pdfinfo the obsolete RC4 algorithm was used:
pdfinfo protect.pdf -upw pwd2
CreationDate: Sat Apr 21 09:10:14 2018 CEST
ModDate: Sat Apr 21 09:10:14 2018 CEST
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 26
Encrypted: yes (print:yes copy:yes change:yes addNotes:yes algorithm:RC4)
Page size: 612 x 792 pts (letter)
Page rot: 0
File size: 288060 bytes
Optimized: no
PDF version: 2.0
According to https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ the PDF 2.0 version is able to encrypt PDF files with the AES-256 standard. How can I do this with ghostscript?
回答1:
The Ghostscript pdfwrite device doesn't support anything except the original RC4 algorithm for encrypting PDF files. The PDF interpreter can decrypt documents using later algorithms.
So as sneep says, you can't do this with Ghostscript and the pdfwrite device.
来源:https://stackoverflow.com/questions/49953421/ghostscript-with-aes-256-password-protection-for-pdf-2-0-documents