You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gary Grosso <ga...@oberontech.com> on 2017/05/26 04:19:21 UTC

PDFormFieldAdditionalActions.setC() not working?

In my project, I could not get setC to do anything, so I modified the CreateSimpleForm.java code to create 2 fields (just in case that mattered), which resulted in http://aapro.net/PDF/SimpleForm.pdf.

Then I commented out a lot of distracting other event handling in FieldTriggers.java, and duplicated everything to handle both fields, resulting in http://aapro.net/PDF/FieldTriggers.java . This, when run gives http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something like this:

AcroForm: (3) [3 0 R]
   DA: /Helv o Tfo g
   DR: (1) [70 R]
     Fields: (2)
       0: (12) [SOR] /T:Annot /S:Widget
       1: (11) [60R] /T:Annot /S:Widget
         AA: (2) [120 R]
             C: (3) [19 O R] /T:Action
                 JS: app.alert("On 'recalculate' action")
                 S: Javascript
                 Type: Action
             D: (3) [13 o R] /T:Action
                 JS: app.alert("On 'mouse down' action")
                 S: Javascript
                 Type: Action

Whatever I do, much as in my original project, I never see "On 'recalculate' action".

I get the expected (if somewhat annoying) behavior for setK, setF, and setV. Why not setC?

Thanks,
Gary



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


Re: PDFormFieldAdditionalActions.setC() not working?

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
> Am 30.05.2017 um 15:52 schrieb Gary Grosso <ga...@oberontech.com>:
> 
> I'll have to learn more about how this works, but at least things are firing now. Thanks!

good - feel free to ask if there are more questions.

BR
Maruan

> 
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
> Sent: Sunday, May 28, 2017 11:23 PM
> To: users@pdfbox.apache.org
> Subject: RE: PDFormFieldAdditionalActions.setC() not working?
> 
> Thanks so much, Maruan. It's too late now, but I'll surely give this a try tomorrow.
> 
> Gary
> 
> 
> -----Original Message-----
> From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de] 
> Sent: Sunday, May 28, 2017 3:40 PM
> To: users@pdfbox.apache.org
> Subject: Re: PDFormFieldAdditionalActions.setC() not working?
> 
> Hi,
> 
>> Am 28.05.2017 um 20:04 schrieb Gary Grosso <ga...@oberontech.com>:
>> 
>> I'm hoping someone has done calculations or other actions as the result of a textfield changing and can share their experience with me.
> 
> you are missing to set the calculation order entry which is requiored if there are calculations.
> 
> Add something like this:
> 
>        PDField field = acroform.getField("SampleField2");
>        COSArray calculationOrder = new COSArray();
>        calculationOrder.add(field);
>        acroform.getCOSObject().setItem("CO", calculationOrder);
> 
> 
> BR
> Maruan
> 
> 
>> 
>> Thanks,
>> Gary
>> 
>> 
>> -----Original Message-----
>> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
>> Sent: Friday, May 26, 2017 6:12 AM
>> To: users@pdfbox.apache.org
>> Subject: RE: PDFormFieldAdditionalActions.setC() not working?
>> 
>> In general, I can execute JavaScript from PDAnnotationAdditionalActions.setPO() to set the current date as a field value, but I need to dynamically fill in some fields as the result of a calculation using two or more other fields, and can't seem to do that. Perhaps I'm going about it the wrong way? I can't seem to get anything at all to fire as the result of a text field changing.
>> 
>> -----Original Message-----
>> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
>> Sent: Friday, May 26, 2017 12:19 AM
>> To: users@pdfbox.apache.org
>> Subject: PDFormFieldAdditionalActions.setC() not working?
>> 
>> In my project, I could not get setC to do anything, so I modified the CreateSimpleForm.java code to create 2 fields (just in case that mattered), which resulted in http://aapro.net/PDF/SimpleForm.pdf.
>> 
>> Then I commented out a lot of distracting other event handling in FieldTriggers.java, and duplicated everything to handle both fields, resulting in http://aapro.net/PDF/FieldTriggers.java . This, when run gives http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something like this:
>> 
>> AcroForm: (3) [3 0 R]
>>  DA: /Helv o Tfo g
>>  DR: (1) [70 R]
>>    Fields: (2)
>>      0: (12) [SOR] /T:Annot /S:Widget
>>      1: (11) [60R] /T:Annot /S:Widget
>>        AA: (2) [120 R]
>>            C: (3) [19 O R] /T:Action
>>                JS: app.alert("On 'recalculate' action")
>>                S: Javascript
>>                Type: Action
>>            D: (3) [13 o R] /T:Action
>>                JS: app.alert("On 'mouse down' action")
>>                S: Javascript
>>                Type: Action
>> 
>> Whatever I do, much as in my original project, I never see "On 'recalculate' action".
>> 
>> I get the expected (if somewhat annoying) behavior for setK, setF, and setV. Why not setC?
>> 
>> Thanks,
>> Gary
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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
>> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 


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


RE: PDFormFieldAdditionalActions.setC() not working?

Posted by Gary Grosso <ga...@oberontech.com>.
I'll have to learn more about how this works, but at least things are firing now. Thanks!

-----Original Message-----
From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
Sent: Sunday, May 28, 2017 11:23 PM
To: users@pdfbox.apache.org
Subject: RE: PDFormFieldAdditionalActions.setC() not working?

Thanks so much, Maruan. It's too late now, but I'll surely give this a try tomorrow.

Gary


-----Original Message-----
From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de] 
Sent: Sunday, May 28, 2017 3:40 PM
To: users@pdfbox.apache.org
Subject: Re: PDFormFieldAdditionalActions.setC() not working?

Hi,

> Am 28.05.2017 um 20:04 schrieb Gary Grosso <ga...@oberontech.com>:
> 
> I'm hoping someone has done calculations or other actions as the result of a textfield changing and can share their experience with me.

you are missing to set the calculation order entry which is requiored if there are calculations.

Add something like this:

        PDField field = acroform.getField("SampleField2");
        COSArray calculationOrder = new COSArray();
        calculationOrder.add(field);
        acroform.getCOSObject().setItem("CO", calculationOrder);


BR
Maruan


> 
> Thanks,
> Gary
> 
> 
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
> Sent: Friday, May 26, 2017 6:12 AM
> To: users@pdfbox.apache.org
> Subject: RE: PDFormFieldAdditionalActions.setC() not working?
> 
> In general, I can execute JavaScript from PDAnnotationAdditionalActions.setPO() to set the current date as a field value, but I need to dynamically fill in some fields as the result of a calculation using two or more other fields, and can't seem to do that. Perhaps I'm going about it the wrong way? I can't seem to get anything at all to fire as the result of a text field changing.
> 
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
> Sent: Friday, May 26, 2017 12:19 AM
> To: users@pdfbox.apache.org
> Subject: PDFormFieldAdditionalActions.setC() not working?
> 
> In my project, I could not get setC to do anything, so I modified the CreateSimpleForm.java code to create 2 fields (just in case that mattered), which resulted in http://aapro.net/PDF/SimpleForm.pdf.
> 
> Then I commented out a lot of distracting other event handling in FieldTriggers.java, and duplicated everything to handle both fields, resulting in http://aapro.net/PDF/FieldTriggers.java . This, when run gives http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something like this:
> 
> AcroForm: (3) [3 0 R]
>   DA: /Helv o Tfo g
>   DR: (1) [70 R]
>     Fields: (2)
>       0: (12) [SOR] /T:Annot /S:Widget
>       1: (11) [60R] /T:Annot /S:Widget
>         AA: (2) [120 R]
>             C: (3) [19 O R] /T:Action
>                 JS: app.alert("On 'recalculate' action")
>                 S: Javascript
>                 Type: Action
>             D: (3) [13 o R] /T:Action
>                 JS: app.alert("On 'mouse down' action")
>                 S: Javascript
>                 Type: Action
> 
> Whatever I do, much as in my original project, I never see "On 'recalculate' action".
> 
> I get the expected (if somewhat annoying) behavior for setK, setF, and setV. Why not setC?
> 
> Thanks,
> Gary
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 


---------------------------------------------------------------------
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: PDFormFieldAdditionalActions.setC() not working?

Posted by Gary Grosso <ga...@oberontech.com>.
Thanks so much, Maruan. It's too late now, but I'll surely give this a try tomorrow.

Gary


-----Original Message-----
From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de] 
Sent: Sunday, May 28, 2017 3:40 PM
To: users@pdfbox.apache.org
Subject: Re: PDFormFieldAdditionalActions.setC() not working?

Hi,

> Am 28.05.2017 um 20:04 schrieb Gary Grosso <ga...@oberontech.com>:
> 
> I'm hoping someone has done calculations or other actions as the result of a textfield changing and can share their experience with me.

you are missing to set the calculation order entry which is requiored if there are calculations.

Add something like this:

        PDField field = acroform.getField("SampleField2");
        COSArray calculationOrder = new COSArray();
        calculationOrder.add(field);
        acroform.getCOSObject().setItem("CO", calculationOrder);


BR
Maruan


> 
> Thanks,
> Gary
> 
> 
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
> Sent: Friday, May 26, 2017 6:12 AM
> To: users@pdfbox.apache.org
> Subject: RE: PDFormFieldAdditionalActions.setC() not working?
> 
> In general, I can execute JavaScript from PDAnnotationAdditionalActions.setPO() to set the current date as a field value, but I need to dynamically fill in some fields as the result of a calculation using two or more other fields, and can't seem to do that. Perhaps I'm going about it the wrong way? I can't seem to get anything at all to fire as the result of a text field changing.
> 
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
> Sent: Friday, May 26, 2017 12:19 AM
> To: users@pdfbox.apache.org
> Subject: PDFormFieldAdditionalActions.setC() not working?
> 
> In my project, I could not get setC to do anything, so I modified the CreateSimpleForm.java code to create 2 fields (just in case that mattered), which resulted in http://aapro.net/PDF/SimpleForm.pdf.
> 
> Then I commented out a lot of distracting other event handling in FieldTriggers.java, and duplicated everything to handle both fields, resulting in http://aapro.net/PDF/FieldTriggers.java . This, when run gives http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something like this:
> 
> AcroForm: (3) [3 0 R]
>   DA: /Helv o Tfo g
>   DR: (1) [70 R]
>     Fields: (2)
>       0: (12) [SOR] /T:Annot /S:Widget
>       1: (11) [60R] /T:Annot /S:Widget
>         AA: (2) [120 R]
>             C: (3) [19 O R] /T:Action
>                 JS: app.alert("On 'recalculate' action")
>                 S: Javascript
>                 Type: Action
>             D: (3) [13 o R] /T:Action
>                 JS: app.alert("On 'mouse down' action")
>                 S: Javascript
>                 Type: Action
> 
> Whatever I do, much as in my original project, I never see "On 'recalculate' action".
> 
> I get the expected (if somewhat annoying) behavior for setK, setF, and setV. Why not setC?
> 
> Thanks,
> Gary
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 


---------------------------------------------------------------------
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: PDFormFieldAdditionalActions.setC() not working?

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

> Am 28.05.2017 um 20:04 schrieb Gary Grosso <ga...@oberontech.com>:
> 
> I'm hoping someone has done calculations or other actions as the result of a textfield changing and can share their experience with me.

you are missing to set the calculation order entry which is requiored if there are calculations.

Add something like this:

        PDField field = acroform.getField("SampleField2");
        COSArray calculationOrder = new COSArray();
        calculationOrder.add(field);
        acroform.getCOSObject().setItem("CO", calculationOrder);


BR
Maruan


> 
> Thanks,
> Gary
> 
> 
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
> Sent: Friday, May 26, 2017 6:12 AM
> To: users@pdfbox.apache.org
> Subject: RE: PDFormFieldAdditionalActions.setC() not working?
> 
> In general, I can execute JavaScript from PDAnnotationAdditionalActions.setPO() to set the current date as a field value, but I need to dynamically fill in some fields as the result of a calculation using two or more other fields, and can't seem to do that. Perhaps I'm going about it the wrong way? I can't seem to get anything at all to fire as the result of a text field changing.
> 
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
> Sent: Friday, May 26, 2017 12:19 AM
> To: users@pdfbox.apache.org
> Subject: PDFormFieldAdditionalActions.setC() not working?
> 
> In my project, I could not get setC to do anything, so I modified the CreateSimpleForm.java code to create 2 fields (just in case that mattered), which resulted in http://aapro.net/PDF/SimpleForm.pdf.
> 
> Then I commented out a lot of distracting other event handling in FieldTriggers.java, and duplicated everything to handle both fields, resulting in http://aapro.net/PDF/FieldTriggers.java . This, when run gives http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something like this:
> 
> AcroForm: (3) [3 0 R]
>   DA: /Helv o Tfo g
>   DR: (1) [70 R]
>     Fields: (2)
>       0: (12) [SOR] /T:Annot /S:Widget
>       1: (11) [60R] /T:Annot /S:Widget
>         AA: (2) [120 R]
>             C: (3) [19 O R] /T:Action
>                 JS: app.alert("On 'recalculate' action")
>                 S: Javascript
>                 Type: Action
>             D: (3) [13 o R] /T:Action
>                 JS: app.alert("On 'mouse down' action")
>                 S: Javascript
>                 Type: Action
> 
> Whatever I do, much as in my original project, I never see "On 'recalculate' action".
> 
> I get the expected (if somewhat annoying) behavior for setK, setF, and setV. Why not setC?
> 
> Thanks,
> Gary
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 


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


RE: PDFormFieldAdditionalActions.setC() not working?

Posted by Gary Grosso <ga...@oberontech.com>.
I'm hoping someone has done calculations or other actions as the result of a textfield changing and can share their experience with me.

Thanks,
Gary


-----Original Message-----
From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
Sent: Friday, May 26, 2017 6:12 AM
To: users@pdfbox.apache.org
Subject: RE: PDFormFieldAdditionalActions.setC() not working?

In general, I can execute JavaScript from PDAnnotationAdditionalActions.setPO() to set the current date as a field value, but I need to dynamically fill in some fields as the result of a calculation using two or more other fields, and can't seem to do that. Perhaps I'm going about it the wrong way? I can't seem to get anything at all to fire as the result of a text field changing.

-----Original Message-----
From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
Sent: Friday, May 26, 2017 12:19 AM
To: users@pdfbox.apache.org
Subject: PDFormFieldAdditionalActions.setC() not working?

In my project, I could not get setC to do anything, so I modified the CreateSimpleForm.java code to create 2 fields (just in case that mattered), which resulted in http://aapro.net/PDF/SimpleForm.pdf.

Then I commented out a lot of distracting other event handling in FieldTriggers.java, and duplicated everything to handle both fields, resulting in http://aapro.net/PDF/FieldTriggers.java . This, when run gives http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something like this:

AcroForm: (3) [3 0 R]
   DA: /Helv o Tfo g
   DR: (1) [70 R]
     Fields: (2)
       0: (12) [SOR] /T:Annot /S:Widget
       1: (11) [60R] /T:Annot /S:Widget
         AA: (2) [120 R]
             C: (3) [19 O R] /T:Action
                 JS: app.alert("On 'recalculate' action")
                 S: Javascript
                 Type: Action
             D: (3) [13 o R] /T:Action
                 JS: app.alert("On 'mouse down' action")
                 S: Javascript
                 Type: Action

Whatever I do, much as in my original project, I never see "On 'recalculate' action".

I get the expected (if somewhat annoying) behavior for setK, setF, and setV. Why not setC?

Thanks,
Gary



---------------------------------------------------------------------
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: PDFormFieldAdditionalActions.setC() not working?

Posted by Gary Grosso <ga...@oberontech.com>.
In general, I can execute JavaScript from PDAnnotationAdditionalActions.setPO() to set the current date as a field value, but I need to dynamically fill in some fields as the result of a calculation using two or more other fields, and can't seem to do that. Perhaps I'm going about it the wrong way? I can't seem to get anything at all to fire as the result of a text field changing.

-----Original Message-----
From: Gary Grosso [mailto:gary.grosso@oberontech.com] 
Sent: Friday, May 26, 2017 12:19 AM
To: users@pdfbox.apache.org
Subject: PDFormFieldAdditionalActions.setC() not working?

In my project, I could not get setC to do anything, so I modified the CreateSimpleForm.java code to create 2 fields (just in case that mattered), which resulted in http://aapro.net/PDF/SimpleForm.pdf.

Then I commented out a lot of distracting other event handling in FieldTriggers.java, and duplicated everything to handle both fields, resulting in http://aapro.net/PDF/FieldTriggers.java . This, when run gives http://aapro.net/PDF/FieldTriggers.pdf, which, in PDFDebugger looks something like this:

AcroForm: (3) [3 0 R]
   DA: /Helv o Tfo g
   DR: (1) [70 R]
     Fields: (2)
       0: (12) [SOR] /T:Annot /S:Widget
       1: (11) [60R] /T:Annot /S:Widget
         AA: (2) [120 R]
             C: (3) [19 O R] /T:Action
                 JS: app.alert("On 'recalculate' action")
                 S: Javascript
                 Type: Action
             D: (3) [13 o R] /T:Action
                 JS: app.alert("On 'mouse down' action")
                 S: Javascript
                 Type: Action

Whatever I do, much as in my original project, I never see "On 'recalculate' action".

I get the expected (if somewhat annoying) behavior for setK, setF, and setV. Why not setC?

Thanks,
Gary



---------------------------------------------------------------------
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