I am trying to use prince in a java app prior to deciding if we want to buy a license. I have put together the following code adn have some questions.
first convert works, generates a pdf, and prints out appropriate message to console. second convert(file), doesn't generate a pdf, and returns fail. third convert prints works to console but doesn't create pdf.
What change should I make to make second convert work? What change do i need to make to third convert to make it generate a pdf? Thanks
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import com.princexml.Prince;
public class someprincetest {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// location of prince command line
Prince p = new Prince("C:\\foo\\prince.exe");
boolean result;
InputStream is = null;
try {
result = p.convert("C:\\foo\\bar\\doc.html");
if (result)
System.out.println("String File Worked");
else
System.out.println("String File Failed");
// location of my html file
File file = new File("C:\\foo\\bar\\doc2.html");
is = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
result = p.convert(is, baos);
if (result)
System.out.println("FileInputStream Worked");
else
System.out.println("FileInputStream Failed");
String html = "<html><head></head><body>hello world</body></html>";
ByteArrayInputStream bs = new ByteArrayInputStream(html.getBytes("UTF-8"));
result = p.convert(bs, baos);
if (result)
System.out.println("ByteArrayInputStream Worked");
else
System.out.println("ByteArrayInputStream Failed");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) {
is.close();
}
}
}
}
first convert works, generates a pdf, and prints out appropriate message to console. second convert(file), doesn't generate a pdf, and returns fail. third convert prints works to console but doesn't create pdf.
What change should I make to make second convert work? What change do i need to make to third convert to make it generate a pdf? Thanks