X-Git-Url: http://www.entropy.ch/git/TestXSLT.git/blobdiff_plain/2692efdcec546bc21bcd388645561c1fe94a90b9..0e9e9d9bedf966c927b0d1faaa1e3271e26be7cd:/FOPWrapper.java diff --git a/FOPWrapper.java b/FOPWrapper.java index 9a97769..aea741a 100644 --- a/FOPWrapper.java +++ b/FOPWrapper.java @@ -23,11 +23,12 @@ public class FOPWrapper { String error; boolean errorOccurred = false; - public NSData convert(String foString) throws IOException, FOPException { + public NSData convert(NSData foData) throws IOException, FOPException { //Construct driver + System.setProperty("java.awt.headless", "true"); Driver driver = new Driver(); - + //Setup logger Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); driver.setLogger(logger); @@ -42,7 +43,7 @@ public class FOPWrapper { driver.setOutputStream(out); //Setup input - InputStream in = new java.io.ByteArrayInputStream(foString.getBytes("UTF-8")); + InputStream in = new java.io.ByteArrayInputStream(foData.bytes(0, foData.length())); try { driver.setInputSource(new InputSource(in)); @@ -59,6 +60,9 @@ public class FOPWrapper { out.close(); } + if (errorOccurred) { + return null; + } return new NSData(out.toByteArray()); }