-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF
Description
When using addJS with PyPDF 1.26.0 on Python 3.6.1 to add Javascript logic to a PDF, this Javascript gets executed twice when opening the PDF instead of once. When using the following sample code, the message box gets shown twice when opening the file in Adobe Reader XI on Windows 7 instead of only once as expected:
from PyPDF2 import PdfReader, PdfWriter
def extract(input_pdf, output_pdf, page):
reader = PdfReader(input_pdf)
writer = PdfWriter()
page = reader.pages[page - 1]
writer.add_page(pdf_page)
writer.add_js('app.alert("Startup");')
with open(output_pdf, "wb") as f:
writer.write(f)Sample usage:
extract("my_file.pdf", "my_file_withjs.pdf", 1)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF