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

internal links not preserved when encrypted #4

Open
iffy opened this issue May 5, 2010 · 1 comment
Open

internal links not preserved when encrypted #4

iffy opened this issue May 5, 2010 · 1 comment

Comments

@iffy
Copy link

iffy commented May 5, 2010

Steps to Duplicate:

  1. Obtain a PDF with internal links (you click the link and it takes you to another page in the PDF)
  2. Encrypt the PDF with the function below
  3. 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)
@cyberixae
Copy link

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?

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

2 participants