Closed chesarin closed 7 years ago
Hi @chesarin,
The idea behind PyV8, which is not part of peepdf, is that you can execute Javascript code from Python. However, you cannot use some of the functions that you would use in a Javascript console like the "print" function. This is something related to PyV8 but not to peepdf. If you want to know the value of the "a" variable in that case you can get the value of that variable with the "js_vars" command, for instance, you don´t really need the "print" function.
PPDF> set jscode "var a = 8; a = a + 2;"
PPDF> js_vars a
10
Sometimes when a PDF document contains JS code it can fail because it contains specific JS functions only present in the Acrobat Reader JS API. In that case, the best way to work with that is extracting the JS code and trying to replace the function with the value that the function would return. There is nothing like that implemented in peepdf yet, but it is something it might be included in the future.
I hope this helps!
I installed pyv8 from https://github.com/buffer/pyv8. The installation of pyv8 succeeded; however, running the following test fails to interpret the javascript code in the variable jscode:
I get similar messages for PDFs that contain javascript and where I execute js_eval.
I ran this test on debian 7.11 and on remnux 6 with the latest version of peepdf found on github. I would appreciate if you can let me know if there is anything else I am missing in order to get peepdf to interpret javascript code.