I'm using Prince 5.1 on Linux. Here's the version info:
I find that the following code does not provide the class implementing the PrinceEvents interface with anything. Here's my reference code:
The class implementing PrinceEvents is PrinceEventHandler, like so:
The execution of the code follows with the sole output to the console as
Note that the PrinceEventHandler did not get invoked with any messages.
The princelog file registered with the Prince object via the setLog call contains the errors found:
The HTML (bad.html) is intentionally invalid. This is what is looks like:
The PDF generated (bad.pdf) is zero bytes in size.
prince --version
YesLogic Prince 5.1 rev 14
Copyright 2002-2007 YesLogic Pty. Ltd.
Demo License
I find that the following code does not provide the class implementing the PrinceEvents interface with anything. Here's my reference code:
public static void main (String[] args) {
try {
Prince p = new Prince("/tmp/prince-5.1/bin/prince", new PrinceEventHandler());
p.setLog("princelog");
p.setEmbedFonts(false);
p.setHTML(false);
FileInputStream fis = new FileInputStream("bad.html");
FileOutputStream fos = new FileOutputStream("bad.pdf");
p.convert(fis, fos);
fis.close();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
The class implementing PrinceEvents is PrinceEventHandler, like so:
class PrinceEventHandler implements PrinceEvents {
public PrinceEventHandler() {
System.out.println("PrinceEventHandler initialized");
}
public void onMessage(String msgType, String msgLoc, String msgText) {
System.out.println("princeOutput: ["+msgType+"] for: "+msgLoc);
System.out.println(msgText);
System.out.flush();
}
}
The execution of the code follows with the sole output to the console as
PrinceEventHandler initialized
Note that the PrinceEventHandler did not get invoked with any messages.
The princelog file registered with the Prince object via the setLog call contains the errors found:
Tue Apr 3 15:34:54 2007: ---- begin
Tue Apr 3 15:34:54 2007: -:8: error: Opening and ending tag mismatch: br line 5 and html
Tue Apr 3 15:34:54 2007: -:8: error: Premature end of data in tag body line 3
Tue Apr 3 15:34:54 2007: -:8: error: Premature end of data in tag html line 1
Tue Apr 3 15:34:54 2007: -: error: could not load input file
Tue Apr 3 15:34:54 2007: finished: failure
Tue Apr 3 15:34:54 2007: ---- end
The HTML (bad.html) is intentionally invalid. This is what is looks like:
<html>
<head><title>This is a title</title></head>
<body>
This is some text. <a>this is text</a>
<br>
That was a bad BR tag.
We aren't closing the body tag either.
</html>
The PDF generated (bad.pdf) is zero bytes in size.