OK, I see... I thought it would be an OutputStream object, but casting to
that didn't work, but casting to FilterOutputStream does work.
I don't think I'll be able to use that to directly open the attached PDF
file, though, or is there a way to do it after all?

On Sun, Apr 4, 2021 at 2:25 PM Tilman Hausherr <[email protected]>
wrote:

> Your screenshot shows COSStream.$1. That's an anonymous class in
> COSStream. And this is the code in COSStream that is used:
>
>          return new FilterOutputStream(cosOut)
>          {
>              @Override
>              public void write(byte[] b, int off, int len) throws
> IOException
>              {
>                  this.out.write(b, off, len);
>              }
>
>              @Override
>              public void close() throws IOException
>              {
>                  super.close();
>                  setInt(COSName.LENGTH, (int)randomAccess.length());
>                  isWriting = false;
>              }
>          };
>
> So your class is a FilterOutputStream, which is an OutputStream.
>
> Tilman
>
> Am 04.04.2021 um 14:20 schrieb Gilad Denneboom:
> >
> https://drive.google.com/file/d/15nTOjbmvysrMhBEg8JF7e6vck80q6J20/view?usp=sharing
> >
> > On Sun, Apr 4, 2021 at 2:12 PM Tilman Hausherr <[email protected]>
> > wrote:
> >
> >> Am 04.04.2021 um 13:48 schrieb Gilad Denneboom:
> >>> 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)?
> >>
> >> I don't see anything because your image was an attachment (mine too but
> >> Thunderbird makes them inline) and your attachment was removed by
> >> Apache. You'll have to upload it somewhere.
> >>
> >> Tilman
> >>
> >>
> >>>
> >>> image.png
> >>>
> >>>
> >>> On Sun, Apr 4, 2021 at 1:43 PM Gilad Denneboom
> >>> <[email protected] <mailto:[email protected]>> 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
> >>>      <[email protected] <mailto:[email protected]>> 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
> >>>          <
> >>
> 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
> >> <
> >>
> 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.
> >>>>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to