hello! i am still facing the previously mentioned problem. as i received no suggestions, i try to show you my problem more precisely:
below you can see my quite straightforward code, and the console output. i have added some println lines to the original itext code, to help following the events behind... any help would be appreciated.. thanks in advance, jb *********************************************** try { RtfParser rtfParser = new RtfParser(); FileInputStream inputStream = new FileInputStream("apple.rtf"); FileOutputStream outputStream = new FileOutputStream("apple.pdf"); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, outputStream); document.open(); System.out.println("Converting.."); rtfParser.convertRtfDocument(inputStream, document); document.close(); System.out.println("Done"); inputStream.close(); outputStream.close(); System.out.println("*********************************"); inputStream = new FileInputStream("apple.rtf"); outputStream = new FileOutputStream("apple.pdf"); Document document2 = new Document(); PdfWriter writer2 = PdfWriter.getInstance(document2, outputStream); document2.open(); System.out.println("Converting.."); rtfParser.convertRtfDocument(inputStream, document2); document2.close(); System.out.print("Done"); } catch(Exception e) { e.printStackTrace(); } *********************************************** document.open() PdfDocument.open() document.open() PdfWriter.open() DocWriter.open() Converting.. Creating section. Entering \footerr Adding \field to document. Adding content to footerRight. Leaving HF section. Inserting break. RtfDestinationDocument.closeDestination() invoked Closing section, adding MultiColumnText to doc. document.close() PdfDocument.close() document.close() PdfWriter.close() PdfDocument.close() DocWriter.close() Done ********************************* document.open() PdfDocument.open() document.open() PdfWriter.open() DocWriter.open() Converting.. Entering \footerr Adding \field to document. Adding content to footerRight. Leaving HF section. com.lowagie.text.DocumentException: The document has been closed. You can't add any Elements. at com.lowagie.text.Document.add(Document.java:257) at hu.rate.rtf2pdf.Section.newPage(Section.java:424) at hu.rate.rtf2pdf.Section.insertBreak(Section.java:473) at hu.rate.rtf2pdf.Section.handleContent(Section.java:319) at com.lowagie.text.rtf.parser.destinations.RtfDestinationDocument.addParagraphToCurrentSection(RtfDestinationDocument.java:596) at com.lowagie.text.rtf.parser.destinations.RtfDestinationDocument.handleControlWord(RtfDestinationDocument.java:390) at com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordHandler.handleControlword(RtfCtrlWordHandler.java:238) at com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordMgr.dispatchKeyword(RtfCtrlWordMgr.java:142) at com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordMgr.handleKeyword(RtfCtrlWordMgr.java:122) at com.lowagie.text.rtf.parser.RtfParser.handleCtrlWord(RtfParser.java:1126) at com.lowagie.text.rtf.parser.RtfParser.parseCtrlWord(RtfParser.java:1504) at com.lowagie.text.rtf.parser.RtfParser.tokenise(RtfParser.java:1330) at com.lowagie.text.rtf.parser.RtfParser.convertRtfDocument(RtfParser.java:530) > hello! > > i'd like to batch convert rtf files to pdf files. > i have no problem with single conversions, > but my program fails with a DocumentException > "The document has been closed. You can't add any Elements" > when i put the whole conversion in a loop iterating over files. > > please give me some hint! > > thanks in advance, > jb. > > for(all the files) { > convert(file) > } > > synchronized convert(file) { > RtfParser = new RtfParser(); > Document document = new Document(); > PdfWriter writer = new PdfWriter.getInstance(document, outputStream); > document.open(); > rtfParser.convertRtfDocument(inputstream, document); > document.close(); > > // not necessary > document = null; > RtfParser = null; > } ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar