You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by chitgoks <ch...@gmail.com> on 2017/08/16 11:00:16 UTC
content stream setGraphicsStateParameters gives null pointer
hi. anyone got ideas why i get a nullpointer when my code looks like this?
square is a PDAnnotation object.
cs.setStrokingColor(square.getInteriorColor());
cs.setNonStrokingColor(square.getInteriorColor());
PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
graphicsState.setStrokingAlphaConstant(0.3f);
cs.setGraphicsStateParameters(graphicsState);
Re: content stream setGraphicsStateParameters gives null pointer
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 16.08.2017 um 13:39 schrieb chitgoks:
> found the culprit
>
> the appearance stream does not have any resources object
>
> so i just instantiated a new one contentStream.setResources(new
> PDResource());
>
> i hope in the near future, new versions will create an instance of this
> automatically.
Although I've hit this problem twice, I didn't make any change in the
code... Sometimes no resources are needed.
Btw you should use the current version before asking *any* question.
Tilman
>
>
> On Wed, Aug 16, 2017 at 7:20 PM, chitgoks <ch...@gmail.com> wrote:
>
>> I'll cook up some code for this
>>
>> the exception stack trace is vague. only shows this
>>
>> SEVERE: null
>> java.lang.NullPointerException
>> at org.apache.pdfbox.pdmodel.PDPageContentStream.
>> setGraphicsStateParameters(PDPageContentStream.java:2199)
>>
>> using pdfbox 2.0.4
>>
>>
>>
>> On Wed, Aug 16, 2017 at 7:16 PM, Maruan Sahyoun <sa...@fileaffairs.de>
>> wrote:
>>
>>>> Am 16.08.2017 um 13:14 schrieb chitgoks <ch...@gmail.com>:
>>>>
>>>> hi maruan. it is actually not null. it draws the shape and color as
>>>> intended. just not transparent.
>>> then I'd need a little more code and the stacktrace - even better would
>>> be a PDF to start from to reproduce (upload it to a public location).
>>> BR
>>> Maruan
>>>
>>>> i added those 3 lines for transparency then i get that null pointer.
>>>>
>>>> Website/Java Games: http://www.chitgoks.com
>>>> My Blogs:
>>>> http://tech.chitgoks.com
>>>> http://wuhtevah.chitgoks.com
>>>> http://disneyusa.blogspot.com
>>>>
>>>> On Wed, Aug 16, 2017 at 7:10 PM, Maruan Sahyoun <sahyoun@fileaffairs.de
>>>>
>>>> wrote:
>>>>
>>>>>> Am 16.08.2017 um 13:00 schrieb chitgoks <ch...@gmail.com>:
>>>>>>
>>>>>> hi. anyone got ideas why i get a nullpointer when my code looks like
>>>>> this?
>>>>>> square is a PDAnnotation object.
>>>>>>
>>>>>> cs.setStrokingColor(square.getInteriorColor());
>>>>>> cs.setNonStrokingColor(square.getInteriorColor());
>>>>> getInteriorColor() might be null if the annotations dictionary doesn't
>>>>> have such an entry
>>>>>
>>>>> BR
>>>>> Maruan
>>>>>
>>>>>> PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
>>>>>> graphicsState.setStrokingAlphaConstant(0.3f);
>>>>>> cs.setGraphicsStateParameters(graphicsState);
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>
>>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: content stream setGraphicsStateParameters gives null pointer
Posted by chitgoks <ch...@gmail.com>.
found the culprit
the appearance stream does not have any resources object
so i just instantiated a new one contentStream.setResources(new
PDResource());
i hope in the near future, new versions will create an instance of this
automatically.
On Wed, Aug 16, 2017 at 7:20 PM, chitgoks <ch...@gmail.com> wrote:
> I'll cook up some code for this
>
> the exception stack trace is vague. only shows this
>
> SEVERE: null
> java.lang.NullPointerException
> at org.apache.pdfbox.pdmodel.PDPageContentStream.
> setGraphicsStateParameters(PDPageContentStream.java:2199)
>
> using pdfbox 2.0.4
>
>
>
> On Wed, Aug 16, 2017 at 7:16 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> wrote:
>
>>
>> > Am 16.08.2017 um 13:14 schrieb chitgoks <ch...@gmail.com>:
>> >
>> > hi maruan. it is actually not null. it draws the shape and color as
>> > intended. just not transparent.
>>
>> then I'd need a little more code and the stacktrace - even better would
>> be a PDF to start from to reproduce (upload it to a public location).
>> BR
>> Maruan
>>
>> >
>> > i added those 3 lines for transparency then i get that null pointer.
>> >
>> > Website/Java Games: http://www.chitgoks.com
>> > My Blogs:
>> > http://tech.chitgoks.com
>> > http://wuhtevah.chitgoks.com
>> > http://disneyusa.blogspot.com
>> >
>> > On Wed, Aug 16, 2017 at 7:10 PM, Maruan Sahyoun <sahyoun@fileaffairs.de
>> >
>> > wrote:
>> >
>> >>
>> >>> Am 16.08.2017 um 13:00 schrieb chitgoks <ch...@gmail.com>:
>> >>>
>> >>> hi. anyone got ideas why i get a nullpointer when my code looks like
>> >> this?
>> >>>
>> >>> square is a PDAnnotation object.
>> >>>
>> >>> cs.setStrokingColor(square.getInteriorColor());
>> >>> cs.setNonStrokingColor(square.getInteriorColor());
>> >>
>> >> getInteriorColor() might be null if the annotations dictionary doesn't
>> >> have such an entry
>> >>
>> >> BR
>> >> Maruan
>> >>
>> >>>
>> >>> PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
>> >>> graphicsState.setStrokingAlphaConstant(0.3f);
>> >>> cs.setGraphicsStateParameters(graphicsState);
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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: content stream setGraphicsStateParameters gives null pointer
Posted by chitgoks <ch...@gmail.com>.
I'll cook up some code for this
the exception stack trace is vague. only shows this
SEVERE: null
java.lang.NullPointerException
at
org.apache.pdfbox.pdmodel.PDPageContentStream.setGraphicsStateParameters(PDPageContentStream.java:2199)
using pdfbox 2.0.4
On Wed, Aug 16, 2017 at 7:16 PM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:
>
> > Am 16.08.2017 um 13:14 schrieb chitgoks <ch...@gmail.com>:
> >
> > hi maruan. it is actually not null. it draws the shape and color as
> > intended. just not transparent.
>
> then I'd need a little more code and the stacktrace - even better would be
> a PDF to start from to reproduce (upload it to a public location).
> BR
> Maruan
>
> >
> > i added those 3 lines for transparency then i get that null pointer.
> >
> > Website/Java Games: http://www.chitgoks.com
> > My Blogs:
> > http://tech.chitgoks.com
> > http://wuhtevah.chitgoks.com
> > http://disneyusa.blogspot.com
> >
> > On Wed, Aug 16, 2017 at 7:10 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> > wrote:
> >
> >>
> >>> Am 16.08.2017 um 13:00 schrieb chitgoks <ch...@gmail.com>:
> >>>
> >>> hi. anyone got ideas why i get a nullpointer when my code looks like
> >> this?
> >>>
> >>> square is a PDAnnotation object.
> >>>
> >>> cs.setStrokingColor(square.getInteriorColor());
> >>> cs.setNonStrokingColor(square.getInteriorColor());
> >>
> >> getInteriorColor() might be null if the annotations dictionary doesn't
> >> have such an entry
> >>
> >> BR
> >> Maruan
> >>
> >>>
> >>> PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
> >>> graphicsState.setStrokingAlphaConstant(0.3f);
> >>> cs.setGraphicsStateParameters(graphicsState);
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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: content stream setGraphicsStateParameters gives null pointer
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
> Am 16.08.2017 um 13:14 schrieb chitgoks <ch...@gmail.com>:
>
> hi maruan. it is actually not null. it draws the shape and color as
> intended. just not transparent.
then I'd need a little more code and the stacktrace - even better would be a PDF to start from to reproduce (upload it to a public location).
BR
Maruan
>
> i added those 3 lines for transparency then i get that null pointer.
>
> Website/Java Games: http://www.chitgoks.com
> My Blogs:
> http://tech.chitgoks.com
> http://wuhtevah.chitgoks.com
> http://disneyusa.blogspot.com
>
> On Wed, Aug 16, 2017 at 7:10 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> wrote:
>
>>
>>> Am 16.08.2017 um 13:00 schrieb chitgoks <ch...@gmail.com>:
>>>
>>> hi. anyone got ideas why i get a nullpointer when my code looks like
>> this?
>>>
>>> square is a PDAnnotation object.
>>>
>>> cs.setStrokingColor(square.getInteriorColor());
>>> cs.setNonStrokingColor(square.getInteriorColor());
>>
>> getInteriorColor() might be null if the annotations dictionary doesn't
>> have such an entry
>>
>> BR
>> Maruan
>>
>>>
>>> PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
>>> graphicsState.setStrokingAlphaConstant(0.3f);
>>> cs.setGraphicsStateParameters(graphicsState);
>>
>>
>> ---------------------------------------------------------------------
>> 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: content stream setGraphicsStateParameters gives null pointer
Posted by chitgoks <ch...@gmail.com>.
hi maruan. it is actually not null. it draws the shape and color as
intended. just not transparent.
i added those 3 lines for transparency then i get that null pointer.
Website/Java Games: http://www.chitgoks.com
My Blogs:
http://tech.chitgoks.com
http://wuhtevah.chitgoks.com
http://disneyusa.blogspot.com
On Wed, Aug 16, 2017 at 7:10 PM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:
>
> > Am 16.08.2017 um 13:00 schrieb chitgoks <ch...@gmail.com>:
> >
> > hi. anyone got ideas why i get a nullpointer when my code looks like
> this?
> >
> > square is a PDAnnotation object.
> >
> > cs.setStrokingColor(square.getInteriorColor());
> > cs.setNonStrokingColor(square.getInteriorColor());
>
> getInteriorColor() might be null if the annotations dictionary doesn't
> have such an entry
>
> BR
> Maruan
>
> >
> > PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
> > graphicsState.setStrokingAlphaConstant(0.3f);
> > cs.setGraphicsStateParameters(graphicsState);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
Re: content stream setGraphicsStateParameters gives null pointer
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
> Am 16.08.2017 um 13:00 schrieb chitgoks <ch...@gmail.com>:
>
> hi. anyone got ideas why i get a nullpointer when my code looks like this?
>
> square is a PDAnnotation object.
>
> cs.setStrokingColor(square.getInteriorColor());
> cs.setNonStrokingColor(square.getInteriorColor());
getInteriorColor() might be null if the annotations dictionary doesn't have such an entry
BR
Maruan
>
> PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
> graphicsState.setStrokingAlphaConstant(0.3f);
> cs.setGraphicsStateParameters(graphicsState);
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org