Search code examples
javascriptjavajakarta-eephantomjsghostdriver

How to run the PhantomJS script from Java-EE application without specification of script full path?


I need to convert some HTML content to PDF or image in my server side app Java EE. For this, I am using the PhantomJS and script "resterize.js".

Problem is, that I need to specify the path of the rasterize.js script. I would like to use only command like this:

phantomjs rasterize.js "https://google.com" test.pdf [my another arguments]

I found it is possible to use GhostDriver and include it into the Java app, but then I dont know, if it is possible to run same rasterize.js script.

Thanks for any answer.


Solution

  • If you don't want to specify the full path in your app, you can define it into an environment variable and then read it like this:

    String base_path = System.getenv("script_base_path");
    

    Does it help you ?