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 2015/12/12 10:11:49 UTC

Applying a Normal Icon appearance to a Push-button

Hi all,

Using PDFBox 1.8.10 (or 2.0.0-RC2, whatever works), is there an option to
set the Normal Icon appearance stream of a push-button? I only see a getter
for this property, not a setter, and attempts to find information online
about how to achieve it have been unsuccessful.

I would appreciate any tips or sample code that will help me solve this
problem...

Thanks in advance, Gilad.

Re: Applying a Normal Icon appearance to a Push-button

Posted by Gilad Denneboom <gi...@gmail.com>.
I'm asking if that's possible. In the meantime I found a hack that solves
the issue though. I use JS to set the stroke color to transparent (even
though it already is), and then the icon magically appears... This suggest
to me that it does have something to do with the appearance of the field
needing to update.

On Wed, Dec 16, 2015 at 2:10 PM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:

> Could you upload a sample file to a public location so I can have a look?
>
> BR
>
> Maruan
>
> > Am 16.12.2015 um 14:04 schrieb Gilad Denneboom <
> gilad.denneboom@gmail.com>:
> >
> > So here's what I did... I created in Acrobat a new PDF file with a button
> > that has the icon I want to use.
> > I load that file in my app and copy the AppearanceCharacteristics and
> > NormalAppearance map from that button into variables.
> > Then I create the button in my main file and apply these two objects to
> its
> > widget. So far as good... I then save the mail file and close both of
> them.
> > When I open the main file in Acrobat I can see the icon I've copied under
> > the Properties of the button field, but it's not visible on the page
> itself.
> > I also set "NeedAppearances" to TRUE, just for good measure, but it
> didn't
> > help.
> >
> > Any ideas?
> >
> > On Sun, Dec 13, 2015 at 8:10 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> > wrote:
> >
> >> If you need additional information please let me know
> >>
> >>
> >>> Am 13.12.2015 um 19:52 schrieb Gilad Denneboom <
> >> gilad.denneboom@gmail.com>:
> >>>
> >>> Thanks for the info, Maruan. I'll play around with it and see what I
> can
> >>> come up with...
> >>>
> >>> On Sun, Dec 13, 2015 at 6:26 PM, Maruan Sahyoun <
> sahyoun@fileaffairs.de>
> >>> wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> you can do
> >>>>
> >>>> PDAnnotationWidget widget = field.getWidgets().get(0);
> >>>> PDAppearanceDictionary apDictionary = widget.getAppearance();
> >>>> apDictionary.setNormalAppearance(PDAppearanceStream stream);
> >>>>
> >>>> Unfortunately for the appearance stream you are on you own as for the
> >>>> exact look of a push button there are no details in the specification.
> >> What
> >>>> you could do is look at the appearance stream as Adobe generates is
> and
> >>>> replicate it.
> >>>>
> >>>> Now if you know how the content should look like you can use
> >>>>
> >>>> PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)
> >>>>
> >>>> which gives you a higher level API to add content to your appearance
> >>>> stream.
> >>>>
> >>>> Hope that helps.
> >>>>
> >>>> BR
> >>>> Maruan
> >>>>
> >>>> PS: I'm planning to add the ability to add some default appearances
> for
> >>>> the different field types when adding new fields via PDFBox but will
> not
> >>>> start before 2.0 has been released.
> >>>>
> >>>>
> >>>>>> Am 12.12.2015 um 10:11 schrieb Gilad Denneboom <
> >>>>> gilad.denneboom@gmail.com>:
> >>>>>
> >>>>> Hi all,
> >>>>>
> >>>>> Using PDFBox 1.8.10 (or 2.0.0-RC2, whatever works), is there an
> option
> >> to
> >>>>> set the Normal Icon appearance stream of a push-button? I only see a
> >>>> getter
> >>>>> for this property, not a setter, and attempts to find information
> >> online
> >>>>> about how to achieve it have been unsuccessful.
> >>>>>
> >>>>> I would appreciate any tips or sample code that will help me solve
> this
> >>>>> problem...
> >>>>>
> >>>>> Thanks in advance, 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
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Applying a Normal Icon appearance to a Push-button

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Could you upload a sample file to a public location so I can have a look?

BR

Maruan

> Am 16.12.2015 um 14:04 schrieb Gilad Denneboom <gi...@gmail.com>:
> 
> So here's what I did... I created in Acrobat a new PDF file with a button
> that has the icon I want to use.
> I load that file in my app and copy the AppearanceCharacteristics and
> NormalAppearance map from that button into variables.
> Then I create the button in my main file and apply these two objects to its
> widget. So far as good... I then save the mail file and close both of them.
> When I open the main file in Acrobat I can see the icon I've copied under
> the Properties of the button field, but it's not visible on the page itself.
> I also set "NeedAppearances" to TRUE, just for good measure, but it didn't
> help.
> 
> Any ideas?
> 
> On Sun, Dec 13, 2015 at 8:10 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> wrote:
> 
>> If you need additional information please let me know
>> 
>> 
>>> Am 13.12.2015 um 19:52 schrieb Gilad Denneboom <
>> gilad.denneboom@gmail.com>:
>>> 
>>> Thanks for the info, Maruan. I'll play around with it and see what I can
>>> come up with...
>>> 
>>> On Sun, Dec 13, 2015 at 6:26 PM, Maruan Sahyoun <sa...@fileaffairs.de>
>>> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> you can do
>>>> 
>>>> PDAnnotationWidget widget = field.getWidgets().get(0);
>>>> PDAppearanceDictionary apDictionary = widget.getAppearance();
>>>> apDictionary.setNormalAppearance(PDAppearanceStream stream);
>>>> 
>>>> Unfortunately for the appearance stream you are on you own as for the
>>>> exact look of a push button there are no details in the specification.
>> What
>>>> you could do is look at the appearance stream as Adobe generates is and
>>>> replicate it.
>>>> 
>>>> Now if you know how the content should look like you can use
>>>> 
>>>> PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)
>>>> 
>>>> which gives you a higher level API to add content to your appearance
>>>> stream.
>>>> 
>>>> Hope that helps.
>>>> 
>>>> BR
>>>> Maruan
>>>> 
>>>> PS: I'm planning to add the ability to add some default appearances for
>>>> the different field types when adding new fields via PDFBox but will not
>>>> start before 2.0 has been released.
>>>> 
>>>> 
>>>>>> Am 12.12.2015 um 10:11 schrieb Gilad Denneboom <
>>>>> gilad.denneboom@gmail.com>:
>>>>> 
>>>>> Hi all,
>>>>> 
>>>>> Using PDFBox 1.8.10 (or 2.0.0-RC2, whatever works), is there an option
>> to
>>>>> set the Normal Icon appearance stream of a push-button? I only see a
>>>> getter
>>>>> for this property, not a setter, and attempts to find information
>> online
>>>>> about how to achieve it have been unsuccessful.
>>>>> 
>>>>> I would appreciate any tips or sample code that will help me solve this
>>>>> problem...
>>>>> 
>>>>> Thanks in advance, 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
>> 
>> 


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


Re: Applying a Normal Icon appearance to a Push-button

Posted by Gilad Denneboom <gi...@gmail.com>.
So here's what I did... I created in Acrobat a new PDF file with a button
that has the icon I want to use.
I load that file in my app and copy the AppearanceCharacteristics and
NormalAppearance map from that button into variables.
Then I create the button in my main file and apply these two objects to its
widget. So far as good... I then save the mail file and close both of them.
When I open the main file in Acrobat I can see the icon I've copied under
the Properties of the button field, but it's not visible on the page itself.
I also set "NeedAppearances" to TRUE, just for good measure, but it didn't
help.

Any ideas?

On Sun, Dec 13, 2015 at 8:10 PM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:

> If you need additional information please let me know
>
>
> > Am 13.12.2015 um 19:52 schrieb Gilad Denneboom <
> gilad.denneboom@gmail.com>:
> >
> > Thanks for the info, Maruan. I'll play around with it and see what I can
> > come up with...
> >
> > On Sun, Dec 13, 2015 at 6:26 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> > wrote:
> >
> >> Hi,
> >>
> >> you can do
> >>
> >> PDAnnotationWidget widget = field.getWidgets().get(0);
> >> PDAppearanceDictionary apDictionary = widget.getAppearance();
> >> apDictionary.setNormalAppearance(PDAppearanceStream stream);
> >>
> >> Unfortunately for the appearance stream you are on you own as for the
> >> exact look of a push button there are no details in the specification.
> What
> >> you could do is look at the appearance stream as Adobe generates is and
> >> replicate it.
> >>
> >> Now if you know how the content should look like you can use
> >>
> >> PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)
> >>
> >> which gives you a higher level API to add content to your appearance
> >> stream.
> >>
> >> Hope that helps.
> >>
> >> BR
> >> Maruan
> >>
> >> PS: I'm planning to add the ability to add some default appearances for
> >> the different field types when adding new fields via PDFBox but will not
> >> start before 2.0 has been released.
> >>
> >>
> >>>> Am 12.12.2015 um 10:11 schrieb Gilad Denneboom <
> >>> gilad.denneboom@gmail.com>:
> >>>
> >>> Hi all,
> >>>
> >>> Using PDFBox 1.8.10 (or 2.0.0-RC2, whatever works), is there an option
> to
> >>> set the Normal Icon appearance stream of a push-button? I only see a
> >> getter
> >>> for this property, not a setter, and attempts to find information
> online
> >>> about how to achieve it have been unsuccessful.
> >>>
> >>> I would appreciate any tips or sample code that will help me solve this
> >>> problem...
> >>>
> >>> Thanks in advance, 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: Applying a Normal Icon appearance to a Push-button

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
If you need additional information please let me know 


> Am 13.12.2015 um 19:52 schrieb Gilad Denneboom <gi...@gmail.com>:
> 
> Thanks for the info, Maruan. I'll play around with it and see what I can
> come up with...
> 
> On Sun, Dec 13, 2015 at 6:26 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> wrote:
> 
>> Hi,
>> 
>> you can do
>> 
>> PDAnnotationWidget widget = field.getWidgets().get(0);
>> PDAppearanceDictionary apDictionary = widget.getAppearance();
>> apDictionary.setNormalAppearance(PDAppearanceStream stream);
>> 
>> Unfortunately for the appearance stream you are on you own as for the
>> exact look of a push button there are no details in the specification. What
>> you could do is look at the appearance stream as Adobe generates is and
>> replicate it.
>> 
>> Now if you know how the content should look like you can use
>> 
>> PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)
>> 
>> which gives you a higher level API to add content to your appearance
>> stream.
>> 
>> Hope that helps.
>> 
>> BR
>> Maruan
>> 
>> PS: I'm planning to add the ability to add some default appearances for
>> the different field types when adding new fields via PDFBox but will not
>> start before 2.0 has been released.
>> 
>> 
>>>> Am 12.12.2015 um 10:11 schrieb Gilad Denneboom <
>>> gilad.denneboom@gmail.com>:
>>> 
>>> Hi all,
>>> 
>>> Using PDFBox 1.8.10 (or 2.0.0-RC2, whatever works), is there an option to
>>> set the Normal Icon appearance stream of a push-button? I only see a
>> getter
>>> for this property, not a setter, and attempts to find information online
>>> about how to achieve it have been unsuccessful.
>>> 
>>> I would appreciate any tips or sample code that will help me solve this
>>> problem...
>>> 
>>> Thanks in advance, 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: Applying a Normal Icon appearance to a Push-button

Posted by Gilad Denneboom <gi...@gmail.com>.
Thanks for the info, Maruan. I'll play around with it and see what I can
come up with...

On Sun, Dec 13, 2015 at 6:26 PM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:

> Hi,
>
> you can do
>
> PDAnnotationWidget widget = field.getWidgets().get(0);
> PDAppearanceDictionary apDictionary = widget.getAppearance();
> apDictionary.setNormalAppearance(PDAppearanceStream stream);
>
> Unfortunately for the appearance stream you are on you own as for the
> exact look of a push button there are no details in the specification. What
> you could do is look at the appearance stream as Adobe generates is and
> replicate it.
>
> Now if you know how the content should look like you can use
>
> PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)
>
> which gives you a higher level API to add content to your appearance
> stream.
>
> Hope that helps.
>
> BR
> Maruan
>
> PS: I'm planning to add the ability to add some default appearances for
> the different field types when adding new fields via PDFBox but will not
> start before 2.0 has been released.
>
>
> > Am 12.12.2015 um 10:11 schrieb Gilad Denneboom <
> gilad.denneboom@gmail.com>:
> >
> > Hi all,
> >
> > Using PDFBox 1.8.10 (or 2.0.0-RC2, whatever works), is there an option to
> > set the Normal Icon appearance stream of a push-button? I only see a
> getter
> > for this property, not a setter, and attempts to find information online
> > about how to achieve it have been unsuccessful.
> >
> > I would appreciate any tips or sample code that will help me solve this
> > problem...
> >
> > Thanks in advance, Gilad.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Applying a Normal Icon appearance to a Push-button

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

you can do 

PDAnnotationWidget widget = field.getWidgets().get(0);
PDAppearanceDictionary apDictionary = widget.getAppearance();
apDictionary.setNormalAppearance(PDAppearanceStream stream);

Unfortunately for the appearance stream you are on you own as for the exact look of a push button there are no details in the specification. What you could do is look at the appearance stream as Adobe generates is and replicate it.

Now if you know how the content should look like you can use 

PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)

which gives you a higher level API to add content to your appearance stream.

Hope that helps.

BR
Maruan

PS: I'm planning to add the ability to add some default appearances for the different field types when adding new fields via PDFBox but will not start before 2.0 has been released.


> Am 12.12.2015 um 10:11 schrieb Gilad Denneboom <gi...@gmail.com>:
> 
> Hi all,
> 
> Using PDFBox 1.8.10 (or 2.0.0-RC2, whatever works), is there an option to
> set the Normal Icon appearance stream of a push-button? I only see a getter
> for this property, not a setter, and attempts to find information online
> about how to achieve it have been unsuccessful.
> 
> I would appreciate any tips or sample code that will help me solve this
> problem...
> 
> Thanks in advance, Gilad.


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