After upgrading my iText library from itext-0.92.jar to iText-2.1.7.jar, a
java.lang.RuntimeException is thrown by
com.lowagie.text.pdf.PdfWriter.getDirectContent(Unknown Source). The exception
message is "The document is not open."
Here's a portion of the stack trace:
[4/19/10 14:37:44:579 EDT] 00000034 SystemErr R java.lang.RuntimeException:
The document is not open.
at java.lang.Throwable.<init>(Throwable.java:195)
at java.lang.Exception.<init>(Exception.java:41)
at java.lang.RuntimeException.<init>(RuntimeException.java:43)
at com.lowagie.text.pdf.PdfWriter.getDirectContent(Unknown Source)
at com.odfl.ws.ODPickup_v2.BolDocument.buildPdf(BolDocument.java:251)
Here's the code:
try {
// Get the template's page 1 attributes.
Rectangle pageSize = pdfReader.getPageSize(1);
// Create a document object for the new BOL.
Document newBolDoc = new Document(pageSize, 50, 50, 50, 50);
// Create an output stream to write the BOL document to a file.
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
// Create a writer to link the new BOL document to its output stream.
PdfWriter bolWriter = PdfWriter.getInstance(newBolDoc, outStream);
// Get a reference to the template page.
PdfImportedPage templatePage = bolWriter.getImportedPage(pdfReader, 1);
// Create a content object for positioning and formatting text on the page.
PdfContentByte bolContent = bolWriter.getDirectContent();
Any ideas?
Regards,
Thomas
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/