how to modify combobox Item from loaded PDF?

class when we load PDF existing, this class we cannot add/remove items in combobox PDF:

https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Parsing.PdfLoadedComboBoxField.html


class to create new combobox in new PDF, with this class we can add/remove items in combobox PDF:

https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Interactive.PdfComboBoxField.html


How can we can modify combobox (add/remove items) from existing PDF?


Thank you


5 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team May 31, 2023 01:13 PM UTC

As of now, we don't have support to add a new item on the combo box field. However we have support to remove the items from the combo box field from the PDF document with the below API. 

https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Parsing.PdfLoadedComboBoxField.html#Syncfusion_Pdf_Parsing_PdfLoadedComboBoxField_Remove_Syncfusion_Pdf_Parsing_PdfLoadedComboBoxItem_


But we are experiencing an known bug with this API as of now. We are currently validating on this and will provide the further details on June 2nd, 2023. 




IJ Irfana Jaffer Sadhik Syncfusion Team June 6, 2023 01:59 PM UTC

On our further analysis, we do not have support to modify combobox Items from loaded pdf document. However,  we have considered this requirement as a usability feature with “Support to modify Combobox Field item from the PdfLoadedDocument” and we will include this support in our 2023 Volume 3 Main release which will be available at the end of September 2023 tentatively.


Please use the below feedback link to track the status of this feature.

https://www.syncfusion.com/feedback/44235/support-to-modify-combobox-field-item-from-the-pdfloadeddocument



RB Ravikumar Baladhandapani Syncfusion Team August 14, 2023 06:44 AM UTC

Upon conducting a more extensive analysis, we have discovered that we possess an existing API for the addition or removal of items within the combo box. The manipulation of combo box items is achieved through the utilization of the Values property. To update the items in the combo box, you can make use of the following API.


//Load the existing PDF document.

PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream);

 

//Load the form field collections from the form.

PdfLoadedFormFieldCollection fieldCollection = loadedDocument.Form.Fields;

 

//Get the combo box fields.

PdfLoadedComboBoxField loadedField = fieldCollection[0] as PdfLoadedComboBoxField;

 

//Get the combo box values.

PdfLoadedListItemCollection values = loadedField.Values;

 

//Remove the first item from the combo box.

values.RemoveAt(0);

 

//Add new item to the combo box.

values.Add(new PdfLoadedListItem("NewDoc", "newvalue"));

 

MemoryStream newstream = new MemoryStream();

 

//Save and close the document.

loadedDocument.Save(newstream);

loadedDocument.Close(true);



RE Remi March 25, 2025 06:17 PM UTC

Hi,


Thanks for this answer.


If you add empty string then you can't read it later. 

<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="29.1.33" />


values.Add(new PdfLoadedListItem("", ""));

values.Add(new PdfLoadedListItem("NewDoc", "newvalue"));

Save


Open in Acrobat Reader, select NewDoc and save it.


Open PDF, find the combobox

pdfLoadedDocument.Form.Fields.TryGetField("mycombo", out PdfLoadedField field);

PdfLoadedComboBoxField comboBox = field as PdfLoadedComboBoxField;

comboBox.SelectedValue => Exception

comboBox.Values => Exception



IJ Irfana Jaffer Sadhik Syncfusion Team March 26, 2025 12:12 PM UTC

Hi Fery,


We were unable to replicate the reported issue on our end. We have attached the sample we used to replicate the issue for your reference. Please share with us the modified sample along with the input document to analyze the issue on our end. 


Since the analysis is based on the provided stack trace, we recommend sharing a sample input PDF document to accurately reproduce and resolve the issue. Please rest assured that Syncfusion maintains strict confidentiality regarding all information disclosed by our customers. We have a Non-Disclosure Agreement in place, ensuring that any documents shared will be used solely for replicating and resolving the issue. These documents will not be shared externally.



Regards,

Irfana J.



Attachment: Create_PDF_fb851765.zip

Loader.
Up arrow icon