Sorry, I see that PDEmbeddedFile extends PDStream, so that is the right function. Then how do you explain this (see the output in the Console)?
[image: image.png] On Sun, Apr 4, 2021 at 1:43 PM Gilad Denneboom <gilad.denneb...@gmail.com> wrote: > You're looking in the wrong place. Look under PDEmbeddedFile's > createOutputStream method. What does it return? > > On Sun, Apr 4, 2021 at 11:53 AM Tilman Hausherr <thaush...@t-online.de> > wrote: > >> Here's what I see in the source code: >> >> >> https://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java?revision=1888047&view=markup#l216 >> >> >> Tilman >> >> Am 04.04.2021 um 11:29 schrieb Gilad Denneboom: >> >> Hi all, >> >> I'm trying to load an embedded PDF file as a new PDDocument object so I can >> read its contents and the way to do it seems to be to get the output stream >> from PDStream, convert it to an ByteArrayOutputStream and then load that >> directly. >> >> However, when I call the createOutputStream method of my PDStream object, >> the output is a COSStream object, not a OutputStream one, as both the >> internal method reference and the online documentation suggest it should be >> (See:https://pdfbox.apache.org/docs/2.0.13/javadocs/org/apache/pdfbox/pdmodel/common/PDStream.html#createOutputStream-- >> ). >> >> Is this an incorrect documentation or implementation? What can I do to >> overcome this issue and load the COSStream object as a new document? >> >> I'm using PDFBox 2.0.23, by the way. >> >> Regards, Gilad. >> >> >> >>