That's a very helpful summary. As far as not mentioning it, that's fine 
as far as the text is concerned, but it probably should be included on 
the class diagram of the PdfWriter since that's highly technical and 
should really correspond to the visible properties and methods of the 
classes. Otherwise it left me thinking that a) the class diagram 
represented a different version than the distributed software (which it 
does) or b) there was a difference between the .NET and java versions 
(which there is not).

After 40 years in this business, I've become a lot like a compiler. I've 
become very literal and rarely assume anything. When something is not 
mentioned, I assume it does not exist, and when it is mentioned, I 
assume that I should understand it and be able to make it work. Also, 
reading the words and grasping the meaning at the conceptual level is 
one thing (I read ch 17 and the anecdote) but since I have very little 
experience with web programming, that cognitive understanding does not 
always translate into the practical ability to implement without some 
trial and error. It's only then that you can fully appreciate those 
things that you only thought you understood when you first read them,

The only reason that I thought I might want to keep the stream open was 
that I might want to write it to a database after sending it to the 
browser. Now that I understand that the ToArray method can be used on a 
closed stream, I can't think of any reason to keep it open either.

Even if you're adding them to a zip, you could just as easily add them 
pone at a time, rather than concatenating them into a stream.

Other than wanting to write the same stream to multiple destinations, 
I'm not sure why I would ever want to introduce a memory stream into the 
picture.

Dan

Bruno Lowagie wrote:
> 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/
> 


-------------------------------------------------------------------------
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/

Reply via email to