Loading data from database into pdf form and vice versa  SOLVED

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, 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.
Post Reply
Bernhard
User
Posts: 7
Joined: Thu Oct 27, 2016 3:36 pm

Loading data from database into pdf form and vice versa

Post by Bernhard »

Hello,
I recently started to develop a module in c# that has to load data from a database to pdf forms and vice versa. My problem is, that I'm able to set values in checkbox buttons but I have no idea howto set the value in a radio button. Please send me some sample code that shows howto set/get values in radio buttons and combo/list boxes.

Regards
Bernhard
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Loading data from database into pdf form and vice versa

Post by Sasha - Tracker Dev Team »

Hello Bernhard,

It seems that the IPXC_FormField::CheckWidget method was not implemented to the full extent so it could not check the Radio Button. I've updated it and now it should work (the fix will be available in the next official release 319). To get checked value of the radio\checkbox use the IsItemSelected method.
As for the Lists\ComboBoxes - the InsertOptRecord (this allows adding elements) was not working when the List\Combo contained 0 elements - fixed that (also in the next release). To get values from the List\Combo use the GetOpt method.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Bernhard
User
Posts: 7
Joined: Thu Oct 27, 2016 3:36 pm

Re: Loading data from database into pdf form and vice versa

Post by Bernhard »

Hello Alex,
Thank you for your help. The "nightly build" didn't solve my problems.

Let's say there is a field of radio buttons like the following:
---
FieldType: Button
FieldName: RadioButtonFieldName
FieldFlags: 49152
FieldValue:
FieldJustification: Left
FieldStateOption: 0
FieldStateOption: 1
FieldStateOption: 2
FieldStateOption: Off
---

How can I get the list of value options ( 0, 1, 2, Off )?
How can I set the button to value "2"?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Loading data from database into pdf form and vice versa

Post by Sasha - Tracker Dev Team »

Hello Bernhard,

Could you lease show us what you have in mind by using a screenshot from the End-User Editor?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Bernhard
User
Posts: 7
Joined: Thu Oct 27, 2016 3:36 pm

Re: Loading data from database into pdf form and vice versa

Post by Bernhard »

Hello Alex,

The code I previously sent to you was a part of FLD file created from a pdf file.

Thank you
Bernhard
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Loading data from database into pdf form and vice versa

Post by Sasha - Tracker Dev Team »

Can you please provide the analogy in the PDF file?
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Bernhard
User
Posts: 7
Joined: Thu Oct 27, 2016 3:36 pm

Re: Loading data from database into pdf form and vice versa

Post by Bernhard »

Hello Alex,
Sorry for my delay. Enclosed you'll find a corresponding pdf file.

Thank you
Bernhard
Attachments
TrackerRadioButtonSample.pdf
PDF form with a radiobutton
(759.13 KiB) Downloaded 197 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Loading data from database into pdf form and vice versa

Post by Sasha - Tracker Dev Team »

Hello Bernhard,

This code works for me:

Code: Select all

IPXC_FormField ff = CoreDoc.AcroForm.GetFieldByName("RadioButtonFieldName");
ff.CheckWidget(2, true); //checks 2 radio button
//ff.ClearSelection(); //will remove all of the selections
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Bernhard
User
Posts: 7
Joined: Thu Oct 27, 2016 3:36 pm

Re: Loading data from database into pdf form and vice versa

Post by Bernhard »

How can I get the list of value options ( "0", "1", "2", "Off" )?

These option values vary from field to field because the pdf forms are created manually. Enumerations like "A", "B", "C", "Off" are possible, two.
I have to determine the index in the list if I want to call CheckWidget( index, true ),
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Loading data from database into pdf form and vice versa

Post by Sasha - Tracker Dev Team »

Hello Bernhard,

I will check whether this is possible and will reply here.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Bernhard
User
Posts: 7
Joined: Thu Oct 27, 2016 3:36 pm

Re: Loading data from database into pdf form and vice versa

Post by Bernhard »

Hello Alex,
To my mind it would be sufficient to set the name property of a widget in the list of widgets of a radiobutton. Looping through the list of widgets would be sufficient to determine the index. Is'nt that a solution.

Thanks Bernhard
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Loading data from database into pdf form and vice versa  SOLVED

Post by Sasha - Tracker Dev Team »

Hello Bernhard,

Here's the code snippet:

Code: Select all

PDFXEdit.IPXC_FormField ff = pdfCtl.Doc.CoreDoc.AcroForm.GetFieldByName("RadioButtonFieldName");
if (ff != null)
{
	for (uint i = 0; i < ff.WidgetsCount; i++)
	{
		PDFXEdit.IPXC_Annotation wd = ff.Widget[i];
		string sValue = wd.OnValue;
	}
	ff.CheckWidget(2, true);
}
Also, please read the 12.7.4.2.4 Radio buttons topic of the PDF specification.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply