Skip to content

Instantly share code, notes, and snippets.

@hallvors
Created December 18, 2016 22:49
Show Gist options
  • Save hallvors/1d216f00225e35f3c1271e9df9a00e2e to your computer and use it in GitHub Desktop.
Save hallvors/1d216f00225e35f3c1271e9df9a00e2e to your computer and use it in GitHub Desktop.
import java.io.*;
public class MakePDF {
/*
* Instantiates a Prince object
*/
public static class MessageListener implements com.princexml.PrinceEvents{
public void onMessage(String msgType,
String msgLocation,
String msgText) {
System.out.println(msgText);
}
}
public static void main(String []args) {
System.out.println("Hello Prince"); // prints Hello World
com.princexml.Prince p = new com.princexml.Prince("../../builds/prince-11-win64/bin/prince.exe", new MessageListener());
p.addScript("../../tmp/log-page-count.js");
/* If you use Log.info() in the JS, you need this line enabled: */
// p.setVerbose(true);
try{
p.convert("../../tmp/blank.htm", "../../tmp/blank.pdf");
}catch(IOException e){
System.out.println("Exception!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment