You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gilad Denneboom <gi...@gmail.com> on 2021/04/04 09:29:29 UTC

Incorrect documentation (or implementation) of PDStream

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.

Re: Incorrect documentation (or implementation) of PDStream

Posted by Gilad Denneboom <gi...@gmail.com>.
Thanks!

On Sun, Apr 4, 2021, 15:33 Tilman Hausherr <TH...@t-online.de> wrote:

> The best is to start with the examples
>
>
> https://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java?view=markup
>
> Tilman
>
> Am 04.04.2021 um 14:49 schrieb Gilad Denneboom:
> > My approach was wrong, I think. I needed to use createInputStream for
> what
> > I was after, not createOutputStream... Anyway, thanks for looking into
> it!
> >
> > On Sun, Apr 4, 2021 at 2:41 PM Gilad Denneboom <
> gilad.denneboom@gmail.com>
> > wrote:
> >
> >> 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 <TH...@t-online.de>
> >> 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 <THausherr@t-online.de
> >
> >>>> 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
> >>>>>> <gilad.denneboom@gmail.com <ma...@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
> >>>>>>       <THausherr@t-online.de <ma...@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
> >>>>>>           <
> >>>
> 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: users-unsubscribe@pdfbox.apache.org
> >>> For additional commands, e-mail: users-help@pdfbox.apache.org
> >>>
> >>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Incorrect documentation (or implementation) of PDStream

Posted by Tilman Hausherr <TH...@t-online.de>.
The best is to start with the examples

https://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java?view=markup

Tilman

Am 04.04.2021 um 14:49 schrieb Gilad Denneboom:
> My approach was wrong, I think. I needed to use createInputStream for what
> I was after, not createOutputStream... Anyway, thanks for looking into it!
>
> On Sun, Apr 4, 2021 at 2:41 PM Gilad Denneboom <gi...@gmail.com>
> wrote:
>
>> 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 <TH...@t-online.de>
>> 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 <TH...@t-online.de>
>>>> 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
>>>>>> <gilad.denneboom@gmail.com <ma...@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
>>>>>>       <THausherr@t-online.de <ma...@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
>>>>>>           <
>>> 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: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Incorrect documentation (or implementation) of PDStream

Posted by Gilad Denneboom <gi...@gmail.com>.
My approach was wrong, I think. I needed to use createInputStream for what
I was after, not createOutputStream... Anyway, thanks for looking into it!

On Sun, Apr 4, 2021 at 2:41 PM Gilad Denneboom <gi...@gmail.com>
wrote:

> 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 <TH...@t-online.de>
> 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 <TH...@t-online.de>
>> > 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
>> >>> <gilad.denneboom@gmail.com <ma...@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
>> >>>      <THausherr@t-online.de <ma...@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
>> >>>          <
>> >>
>> 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: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>

Re: Incorrect documentation (or implementation) of PDStream

Posted by Gilad Denneboom <gi...@gmail.com>.
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 <TH...@t-online.de>
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 <TH...@t-online.de>
> > 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
> >>> <gilad.denneboom@gmail.com <ma...@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
> >>>      <THausherr@t-online.de <ma...@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
> >>>          <
> >>
> 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: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Incorrect documentation (or implementation) of PDStream

Posted by Tilman Hausherr <TH...@t-online.de>.
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 <TH...@t-online.de>
> 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
>>> <gilad.denneboom@gmail.com <ma...@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
>>>      <THausherr@t-online.de <ma...@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
>>>          <
>> 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: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Incorrect documentation (or implementation) of PDStream

Posted by Gilad Denneboom <gi...@gmail.com>.
https://drive.google.com/file/d/15nTOjbmvysrMhBEg8JF7e6vck80q6J20/view?usp=sharing

On Sun, Apr 4, 2021 at 2:12 PM Tilman Hausherr <TH...@t-online.de>
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
> > <gilad.denneboom@gmail.com <ma...@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
> >     <THausherr@t-online.de <ma...@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
> >         <
> 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.
> >>
> >
>
>

Re: Incorrect documentation (or implementation) of PDStream

Posted by Tilman Hausherr <TH...@t-online.de>.
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 
> <gilad.denneboom@gmail.com <ma...@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
>     <THausherr@t-online.de <ma...@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
>         <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.
>>
>


Re: Incorrect documentation (or implementation) of PDStream

Posted by Gilad Denneboom <gi...@gmail.com>.
 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 <gi...@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 <TH...@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.
>>
>>
>>
>>

Re: Incorrect documentation (or implementation) of PDStream

Posted by Gilad Denneboom <gi...@gmail.com>.
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 <TH...@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.
>
>
>
>

Re: Incorrect documentation (or implementation) of PDStream

Posted by Tilman Hausherr <TH...@t-online.de>.
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.
>