Hi all,--
I need a little help with running Flying Saucer on a headless linux server.
I have a system that needs to convert html to .pdf files to send to customers on the fly. The HTML is created by my core application (not java) and saved as a file. It then calls a small java app, which turns it into the .pdf.
The app runs fine on my development machine but throws an error when I try to run it on the server. I suspect that the problem might be that I haven't set it up to run on the headless server, but I haven't been able to work out how to do that.
My source code (taken more or less directly from the "for Fun and Profit " tutorial) is as follows:File htmlFile = new File(htmlFileName);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(htmlFile);ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(doc, null);
String outputFile = pdfFileName;
OutputStream os = new FileOutputStream(outputFile);
renderer.layout();
renderer.createPDF(os);
os.close();
and I am receiving the following error when I run it on the server:
java.io.IOException: Stream closedat java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:151)at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)at java.io.BufferedInputStream.read(BufferedInputStream.java:334)at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)at java.io.InputStreamReader.read(InputStreamReader.java:184)at org.xhtmlrenderer.css.parser.Lexer.zzRefill(Lexer.java:1634)at org.xhtmlrenderer.css.parser.Lexer.yylex(Lexer.java:1865)at org.xhtmlrenderer.css.parser.CSSParser.next(CSSParser.java:1798)at org.xhtmlrenderer.css.parser.CSSParser.la(CSSParser.java:1810)at org.xhtmlrenderer.css.parser.CSSParser.stylesheet(CSSParser.java:159)at org.xhtmlrenderer.css.parser.CSSParser.parseStylesheet(CSSParser.java:89)at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:78)at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:95)at org.xhtmlrenderer.context.StylesheetFactoryImpl.getStylesheet(StylesheetFactoryImpl.java:174)at org.xhtmlrenderer.context.StyleReference.readAndParseAll(StyleReference.java:123)at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:107)at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:175)at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:142)at pdf_from_html.pdf_from_html.main(pdf_from_html.java:57)
I would appreciate it if anyone could help me get to the bottom of this.
Thanks
Bevan
You received this message because you are subscribed to the Google Groups "Flying Saucer Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flying-saucer-u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.