cornerpirate / JS2PDFInjector

Inject a JS file into a PDF file.
Apache License 2.0
303 stars 56 forks source link

Run javascript after injection #3

Closed pastean closed 4 years ago

pastean commented 4 years ago

Hello,

Awesome library, thanks for making it open source. I am using it to programatically fill some forms that must have custom formatting on individual words.

I was wondering if it would be possible to run the javascript after injecting the javascript and before exporting the file? so that after I run the command I get the automatically filled forms.

I've been looking around the javascript acrobat api but with no luck so far. Any help would be much appreciated. Thank you

cornerpirate commented 4 years ago

Hi,

I don't think that meets the remit of what this is made to do (test email filtering blocks JavaScript in PDF documents). It is a security tool and I would not suggest using this for your purposes unfortunately.

It sounds like you want to dynamically generate the PDF file contents? In which case technically the dependency JS2PDFInjector uses called "pdfbox-app" is a Java library which can be used to programmatically create a PDF. There are also other options which allow a PDFs to be generated in the same way.

Sorry that I could not be of more help!

pastean commented 4 years ago

Hey,

Thank you for taking the time to answer :) sorry for not replying earlier.

After doing some more digging I found out that in order for the JS to run, the program I use to open the said PDF needs a JS engine implemented, just like adobe acrobat has. Unfortunately I haven't found out anything else on this topic and just moved on to pdf-fill-form library and used it for the purpose above, and gave in to some limitations I had in earlier.