We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Importxml and combo/listbox

Hi

Is it possible to use importXML to also fill combo and listboxes with values?

If possible, can you show me how?

Regards

Christer Dalevind

Hello Christer,

Thanks for using our products.

I am pleased to inform you that ImportXML(....) method can be used to fill ComboBox and ListBox fields inside the PDF document. Please make sure that the name of Form field mentioned in XML file is same as present in the PDF form being filled.

Let think of a scenario in which we have a simple PDF form containing two form field items i.e. ComboBox and ListBox. Name of these fields are combobox1 and list1 respectively. Now in order to fill these form fields, we can use following XML contents.

[C#]

//Assign input and output PDF documents
Aspose.Pdf.Kit.Form form = new Aspose.Pdf.Kit.Form(@"d:/pdftest/SamplePDF_Updated.pdf", @"d:/pdftest/SamplePDF_Filled.pdf");
//Create an XML file as a FileStream that contains the contents of the PDF document
System.IO.FileStream xmlInputStream = new FileStream(@"d:/pdftest/SampleXML.xml", FileMode.Open);

//Import the values from the XML file to the PDF form
form.ImportXml(xmlInputStream);
//Save the output PDF document
form.Save();
//Close the input XML stream
xmlInputStream.Close();

[XML]

<?xml version="1.0" encoding="utf-8"?>
<fields>
<field name="combobox1">
<value> ComboItem3</value>
</field>
<field name="list1">
<value>ListItem1</value>
</field>
</fields>

For more related information, please visit the following link. Import and Export into XML

I have also attached the source PDF form and the filled PDF document. In case you face any problem or you have any further query, please feel free to contact.

Hello codewarior and thanks very much for your quick reply.

Maybe I'm mixing up terms here, but do you by filling mean the same as selecting a value from already existing values in the boxes? In that case I meant if it is possible to add new items to combo/listboxes with importXML?

Regards

Christer Dalevind

Hello Christer,

Thanks for the additional information.

I am afraid the requested feature of adding items to existing ComboBox and ListBox controls, is currently not supported. However, for the sake of implementation, I have logged this requirement as PDFKITNET-20730 in our issue tracking system under new features list. We will further look into the details of this requirement and will keep you updated on the status of implementation.

Please be patient and spare us little time. We apologize for your inconvenience.