Hi
I'm attempting to insert JS that opens the URL whenever the user opens the PDF. Whatever JS I add, it executes it twice. In my scenario, Adobe Acrobat is alerting me about security twice because the same JS was executed twice.
Environment
Plaform: Linux-4.15.0-108-generic-x86_64-with-Ubuntu-18.04-bionic
PyPDF2 Version: 1.26.0
Python : 3.6.9
Code + PDF
from PyPDF2 import PdfFileWriter, PdfFileReader
output = PdfFileWriter()
ipdf = PdfFileReader(open('test.pdf', 'rb'))
for i in range(ipdf.getNumPages()):
page = ipdf.getPage(i)
output.addPage(page)
with open('updated_pdf.pdf', 'wb') as f:
output.addJS('app.launchURL("https://google.com/", true);')
output.write(f)
test.pdf
updated_pdf.pdf
Todo:
JS should be executed only once
Hi
I'm attempting to insert JS that opens the URL whenever the user opens the PDF. Whatever JS I add, it executes it twice. In my scenario, Adobe Acrobat is alerting me about security twice because the same JS was executed twice.
Environment
Plaform:
Linux-4.15.0-108-generic-x86_64-with-Ubuntu-18.04-bionicPyPDF2 Version:
1.26.0Python : 3.6.9
Code + PDF
test.pdf
updated_pdf.pdf
Todo:
JS should be executed only once