Andrea, AndreaC. wrote > I'm very confused about the new * > PdfRead * > class version. > > ... > > It seems that now isn't possible to read through an InputStream without > closing it. Is it correct? What I'm wrong?
It's hard to contradict your source code references. Indeed, if you instantiate a PdfReader using a constructor with an InputStream argument, the close method of that stream will be called. In a way that does make sense as the stream contents are read until "the end of the stream has been reached." If you want to prevent this (e.g. because closing the InputStream has undesirable side effects like cutting some connection, or because the caller providing that InputStream insists on being the code to also close it), there are two obvious ways to prevent that: 1. Create an InputStream wrapper class which ignores the close() call and forwards all other calls. Wrap your InputStream in such a wrapper object and use that wrapper object to construct the PdfReader. 2. Looking at the code you found it becomes apparent that iText reads the whole stream into a byte[] to process it. Thus, you can do the same, copy the contents of the stream to a byte[] (or even some temporary file to decrease memory consumption) without finally closing the stream and use a PdfReader constructor accepting that byte[] or file. Regards, Michael -- View this message in context: http://itext-general.2136553.n4.nabble.com/PdfReader-close-the-given-InputStream-tp4660430p4660431.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Slashdot TV. Videos for Nerds. Stuff that Matters. http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php