I have raised a SO question and was suggested to raise the issue in this forum.
Basically, I have a XFA based PDF and I have to programmatically manipulate the fields in it.
I am using JAVA API.
I could manipulate text fields, but failed to do so for radio buttons.
In attached file, there is a radio button on page 2(Language for correspondence:). I am trying to select ‘English’ option, but I am not sure how to do it.
Thank you.
PS:
Also, I see a strange yellow box with a message in first page after manipulation:
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-42424
You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.
I haven’t worked on your ticket but I am retrieving the information from it for you.
This was fixed in: * Target version set to Aspose.PDF 23.3
This are the valuable comments from the dev that worked in the ticket:
To change the value of any field we should initially get the name of that field.
Here is a 2 ways to receive the fields’ names:
String id = "CISA-declaration-dpetp-en_RAW";
Document doc = new Document(dataDir+ id + ".pdf");
com.aspose.pdf.facades.Form form1 = new com.aspose.pdf.facades.Form();
form1.bindPdf(doc);
//Get the structure of the fields
String xfdf2 = dataDir + id + "-aspose.xfdf";
FileOutputStream xfdfOutputStream = new FileOutputStream(xfdf2);
form1.exportXfdf(xfdfOutputStream);
xfdfOutputStream.close();
//or
XFA xfa = doc.getForm().get_xfa();
//Get a list of fields
String[] list = xfa.getFieldNames();
Note that we can handle a radio button by changing its exact element or the general radio button field setting number from 1 to 3.
The following example for English option. Uncomment any other of the below commented set_item methods to set the radio button option other than English:
String id = "CISA-declaration-dpetp-en_RAW";
Document doc = new Document(dataDir+ id + ".pdf");
XFA xfa = doc.getForm().get_xfa();
// xfa.set_Item("form1[0].Angaben_Effektenhändler_SF[0].Sprache[0].DE[0]", "1");
//or
// xfa.set_Item("form1[0].Angaben_Effektenhändler_SF[0].Sprache[0].FR[0]", "2");
//or
// xfa.set_Item("form1[0].Angaben_Effektenhändler_SF[0].Sprache[0].EN[0]", "3");
// xfa.set_Item("form1[0].Angaben_Effektenhändler_SF[0].Sprache[0]", "1");//GR
//or
// xfa.set_Item("form1[0].Angaben_Effektenhändler_SF[0].Sprache[0]", "2");//GR
//or
xfa.set_Item("form1[0].Angaben_Effektenhändler_SF[0].Sprache[0]", "3");//EN
doc.save(dataDir+ id +"_out_23_3_EN.pdf");
I hope this information is helpful for you.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.