Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error When Decrypting PDF File #123

Open
XxDaShTixX opened this issue Jun 7, 2024 · 0 comments
Open

Error When Decrypting PDF File #123

XxDaShTixX opened this issue Jun 7, 2024 · 0 comments

Comments

@XxDaShTixX
Copy link

XxDaShTixX commented Jun 7, 2024

GhostScript Version

GhostScript v10.03.1

Problem

"Sometimes" I get an error when I decrypt PDF files after I have encrypted them (also using GhostScript). I can't figure out what exactly is causing this.

Error/Issue

I receive the following error when I attempt to decrypt the previously encrypted file (by GhostScript):
GPL Ghostscript 10.03.1: PDFDocEncoding X is undefined
Where "X" can be an alphanumerical character or two.

I noticed that sometimes based on the permission bits I set when encrypting the same file, it can cause it to error out or succeed in the decryption process.

Reproduce Error

  1. Download the sample.pdf file.

  2. Encrypt the sample file twice. Each time with a different permission bit in order to simulate a succeeding and failing decrypting use case using the following commands:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile="Encrypted-8.pdf" -sOwnerPassword="123" -dPermissions=-8 -dEncryptionR=3 "Sample.pdf" -c quit

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile="Encrypted-16.pdf" -sOwnerPassword="123" -dPermissions=-16 -dEncryptionR=3 "Sample.pdf" -c quit

  1. Now try to decrypt each with the same command:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile="Decrypted-8.pdf" -sPDFPassword="123" "Encrypted-8.pdf" -c quit

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile="Decrypted-16.pdf" -sPDFPassword="123" "Encrypted-16.pdf" -c quit

  1. The 8-bit PDF will error. The 16bit PDF will succeed.

Failure:
image

Success:
image

This may be different for different PDF files. Please let me know if you need any further details.
Thank you in advance for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant