Search code examples
javahtmltype-conversionpostscriptxulrunner

Java: how to use xulrunner to convert html to postscript?


I need write a service that receives labels in html format via webservice(Endpoint) in a java SE application and print the same in an automated fashion by controlling the printing and return status (ie, if the document was printed successfully or not).

The problem is I need to convert the html to a print format that the printer(Zebra) accepts, (ie, postscript or image). Is this possible with xulrunner or otherwise (without ZPL Layout)?

Thank you!


Solution

  • You could try integrating PhantomJS with Java using GhostDriver:

    https://github.com/detro/ghostdriver

    Specifically, see the Java code here:

    https://github.com/detro/ghostdriver/blob/master/binding/java/src/main/java/org/openqa/selenium/phantomjs/PhantomJSDriver.java

    This library is available in Maven, so integration might be easy. You can get a screenshot with the getScreenshotAs() function.

    Alternatively, see Embedding XULRunner application on Java if you want to give XULRunner a shot.