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
Obtain a PDF with internal links (you click the link and it takes you to another page in the PDF)
Encrypt the PDF with the function below
Open the PDF and see that the links no longer work.
def encrypt(in_stream, out_stream, user_password, owner_password=None):
"""
Encrypt an existing PDF file (stream)
`in_stream` stream with pdf data
open(filename, 'rb')
`out_stream` stream where output will be written
open(filename, 'wb')
`user_password` the password used for limited access
`owner_password` the password used for full access (defaults to user_password)
I copied this from /sm/script/encryptPdf.py
"""
reader = PdfFileReader(in_stream)
writer = PdfFileWriter()
for i in range(reader.getNumPages()):
writer.addPage(reader.getPage(i))
writer.encrypt(user_password, owner_password)
writer.write(out_stream)
The text was updated successfully, but these errors were encountered:
The bug seems to be present even when you don't encrypt the pdf. I have used PyPdf for watermarking like the example on the front page. That type of usage breaks internal links too, but I also tried simply iterating pages from input, adding them to output and writing the file out. That breaks internal links as well. My best guess is that PyPdf will simply break internal links under all circumstances. Has someone been able to figure out the root cause to this?
Steps to Duplicate:
def encrypt(in_stream, out_stream, user_password, owner_password=None): """ Encrypt an existing PDF file (stream)
The text was updated successfully, but these errors were encountered: