cornerpirate / JS2PDFInjector

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

including complete js file #7

Open umnibot opened 3 years ago

umnibot commented 3 years ago

Hey, this works like a charm with a simple alert, etc. But will it work including a whole js script?

What I want to achieve is to include the js as we do in HTML for example

__

I have tried adding it like this in the js that I am including

var tagString = '<script async type="text/javascript" data-name="myscript" src="https://path_to_script/sdk.js" data-account="Pet" data-language="en"></script>';

var range = document.createRange();
range.selectNode(document.getElementsByTagName("BODY")[0]);
var documentFragment = range.createContextualFragment(tagString);
document.body.appendChild(documentFragment);

But it didn't work. Perhaps there is something else that should be done.

cornerpirate commented 11 months ago

I do not offer support for how to make JS work in PDF files unfortunately. I just needed to confirm a popup for my use case. When I tried to do advanced stuff a few years back I noted that PDF viewers are now more safe out of the box and deny a lot of things.

If you ever got something that worked in then sharing it here might help the community.

Thanks

Kazakov12 commented 8 months ago

Tell me how can I rebuild your java source code for myself?