You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to decrypt a PDF document, while keeping the document intact. The documentation gives an example for this (https://pypdf.readthedocs.io/en/stable/user/encryption-decryption.html); but this decrypts the document, then reconstructs it by copying page by page to the new document.
This removes attachments, but also the table of contents, the links in the document pointing to other pages, ...
I would like an approach where the encrypted data is decrypted 'in-place', keeping the document structure intact.
Environment
Which environment were you using when you encountered the problem?
$ python -m platform
Linux-6.5.0-26-generic-x86_64-with-glibc2.35
$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==4.1.0, crypt_provider=('cryptography', '42.0.5'), PIL=none
(modified by me to add support for the pubsec decryptor, but this doesn't affect anything)
Code + PDF
This is a minimal, complete example that shows the issue; it does not use encryption, but it has the same problem as the sample that does use encryption.
frompypdfimportPdfReader, PdfWriterreader=PdfReader("PN7160_PN7161.pdf")
writer=PdfWriter()
foridx, pageinenumerate(reader.pages):
writer.add_page(page)
print("Saving to file...")
# Save the new PDF to a filewithopen("out.pdf", "wb") asf:
writer.write(f)
I want to decrypt a PDF document, while keeping the document intact. The documentation gives an example for this (https://pypdf.readthedocs.io/en/stable/user/encryption-decryption.html); but this decrypts the document, then reconstructs it by copying page by page to the new document.
This removes attachments, but also the table of contents, the links in the document pointing to other pages, ...
I would like an approach where the encrypted data is decrypted 'in-place', keeping the document structure intact.
Environment
Which environment were you using when you encountered the problem?
Code + PDF
This is a minimal, complete example that shows the issue; it does not use encryption, but it has the same problem as the sample that does use encryption.
PN7160_PN7161.pdf
The text was updated successfully, but these errors were encountered: