Programmatically calculate form fields
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 37
- Joined: Wed Mar 15, 2017 4:01 pm
Programmatically calculate form fields
Calculated acroform fields are not calculating when the contributing field values are supplied programmatically using .SetValueText(). The Forms.AutoCalc setting is True. How can I force them to calculate without user interaction? Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Programmatically calculate form fields
Hello askelly,
I suspect that you have opened the IPXV_Document (Editor Level) and trying to modify it with the IPXC_ interface's methods (Core Level). That is not correct, because the Editor's level does not "know" about your changes done at the Core Level. The method that you illustrated will work when you open the IPXC_Document, use the Core API methods only (that you have illustrated) and then open the IPXC_Document in the Control with OpenDocFrom method and you will see that the changes that you have done were applied correctly.
Cheers,
Alex
I suspect that you have opened the IPXV_Document (Editor Level) and trying to modify it with the IPXC_ interface's methods (Core Level). That is not correct, because the Editor's level does not "know" about your changes done at the Core Level. The method that you illustrated will work when you open the IPXC_Document, use the Core API methods only (that you have illustrated) and then open the IPXC_Document in the Control with OpenDocFrom method and you will see that the changes that you have done were applied correctly.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 37
- Joined: Wed Mar 15, 2017 4:01 pm
Re: Programmatically calculate form fields
Yes, we're using it (incorrectly?) as you described. What you said makes sense, but I'm not sure how to resolve the issue without large changes to our existing Acrobat-based application. We have a function that allows the user to refresh the field data from a database without closing and reopening the document. As far as I can tell there is no way to access form fields other than through IPXC_Document. IPXV_Document has no field collection or widget collection that I can find, so I am unable to make the changes at that level. Also, my code is setting the field values and field border properties within the IPXC_Document while it's already open in the control and those changes are reflected in the control's GUI, so the IPXV_Document does seem to "know" about those changes somehow. It's only the calculations that are not working. So my questions are:
1) If the editor is aware that the value has changed in the underlying IPXC_Document, which evidently is true, then shouldn't it react by re-running calculations using the new value?
2) Is there a way to set a field value at the editor level?
3) Is there a way to initiate field calculation at the editor level?
Thanks!
1) If the editor is aware that the value has changed in the underlying IPXC_Document, which evidently is true, then shouldn't it react by re-running calculations using the new value?
2) Is there a way to set a field value at the editor level?
3) Is there a way to initiate field calculation at the editor level?
Thanks!
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Programmatically calculate form fields
Hello askelly,
Try using these events after you finished modifying the fields on the Core Level to tell the Editor level about this:
https://sdkhelp.pdf-xchange.com/vie ... angedEvent
https://sdkhelp.pdf-xchange.com/vie ... angedEvent
Cheers,
Alex
Try using these events after you finished modifying the fields on the Core Level to tell the Editor level about this:
https://sdkhelp.pdf-xchange.com/vie ... angedEvent
https://sdkhelp.pdf-xchange.com/vie ... angedEvent
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 37
- Joined: Wed Mar 15, 2017 4:01 pm
Re: Programmatically calculate form fields
That doesn't seem to have any impact.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Programmatically calculate form fields
Hello askelly,
Please provide a working sample then so we can advise you further.
Cheers,
Alex
Please provide a working sample then so we can advise you further.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 37
- Joined: Wed Mar 15, 2017 4:01 pm
Re: Programmatically calculate form fields
Please see the attached demo app. It should display a simple PDF form with three fields when it starts. There's a button at the top to fill values in the first two fields, after which the expected behavior is for the third field to display the sum. Thanks.
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Programmatically calculate form fields
Hello askelly,
Adding this piece of code worked for me:
Cheers,
Alex
Adding this piece of code worked for me:
Code: Select all
f = .GetFieldByName("Text3") 'the calculated field
f.UpdateAP()
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 37
- Joined: Wed Mar 15, 2017 4:01 pm
Re: Programmatically calculate form fields
That isn't working for me. Did you make another change also? Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Programmatically calculate form fields
Hello askelly,
Sorry, after further tests, it appears that that sample indeed is not working.
For the correct results, using the Editors Level would be optimal. Using this sample, you can modify a field and the other fields will "know" about it:
Cheers,
Alex
Sorry, after further tests, it appears that that sample indeed is not working.
For the correct results, using the Editors Level would be optimal. Using this sample, you can modify a field and the other fields will "know" about it:
Code: Select all
PDFXEdit.IPXC_FormField ff = pdfCtl.Doc.CoreDoc.AcroForm.GetFieldByName("Text1");
int nID = pdfCtl.Inst.Str2ID("op.fields.modify", false);
PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
var input = Op.Params.Root["Input"];
input.Add().v = ff;
var options = Op.Params.Root["Options"];
options["Mask"].v = 0x00000100; //Value modification
options["Value.Value"].v = "5";
Op.Do();
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 37
- Joined: Wed Mar 15, 2017 4:01 pm
Re: Programmatically calculate form fields
That works. Thanks!
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
Re: Programmatically calculate form fields
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ