Daniel Essin wrote: > The only part that was an iText issues is that in the .NET version of > the PdfWriter, the stream is closed when the document is closed unless > you obtain a reference to the PdfWriter and set the CloseStream property > to false. This property (I think) does not exist in the java version and > is not mentioned in the book.
It is present in the Java version too. I DELIBERATELY didn't mention the method in the book, because you are not supposed to use it. As you can read in chapter 18, PDF documents are read backwards, starting with the trailer at the end, using the cross reference table to find the different objects of the PDF file. Adding extra bytes at the end of a PDF file WILL BREAK the PDF. That's what goes wrong with MSIE as explained in chapter 17. MSIE adds extra garbage bytes that make it impossible for some PDF viewer to render the document. In all those years, I have found only one reason why you might want to keep the underlying output stream open: if you want to create a chain of PDF files that are bundled in an archive like a tar or a zip file. If you know of another reason why you wouldn't want the underlying output stream to be closed, please let me know. In general, I would say you aren't supposed to leave the output stream open because 'bad things can happen' if you add extra stuff to a stream of PDF bytes. If you read the anecdote on page 539 (which is by the way an almost literal description of your problem: 'the file doesn't begin with %PDF'), you know what I'm talking about ;-) I don't think there's essential stuff missing in the book. It's just that you can't expect to understand everything about PDF and iText after reading the book only once. br, Bruno ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/