claird / PyPDF4

A utility to read and write PDFs with Python
obsolete-https://pythonhosted.org/PyPDF2/
Other
330 stars 61 forks source link

Fixed addJS running twice #72

Closed NotWearingPants closed 4 years ago

NotWearingPants commented 4 years ago

Fixes #70

This implements the fix suggested in mstamy2/PyPDF2#482 by @youssef-jaber - replacing /OpenAction with /JavaScript.

I'm not actually sure what this does, so I'm open to suggestions if this isn't a good fix.

douniwan5788 commented 2 years ago

/JavaScript is automatically executed in /Names under /Catalog, you should only use one of /OpenAction and /Names, not both, this is why the https://github.com/py-pdf/PyPDF2/issues/482 bug occurs, /JavaScript is meaningless under /Catalog, so it is completely ignored by pdf. Just removing the line NameObject("/JavaScript"): js_indirect_object, is enough