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

Free Support Forum - aspose.com

Some questions on editing a pdf form

Hi there,

We are using Aspose.pdf.kit (Java) to edit some pdf forms, and have got three questions:

1. I have tried to find some code samples in Aspose.pdf.kit to put value from a datasource (an array) to a a field (typed as a list box) in a pdf form, but could find any. Can you please provide us some codes on that?
2. In an existed pdf form, is that possible to delete a row from a table (or list box)
3. In an existed pdf form, is that possible to delete some sentences by coding by Aspose.pdf.kit? Say, we have three sentence by sequence, S1, S2, S3, is that possible we delete S2 (by coding) and make S3 directly after S1?

Thank you very much!


This message was posted using Page2Forum from Form (Aspose.Pdf.Kit for Java) - Aspose.Pdf.Kit for .NET and Java


Thanks for considering Aspose.

1) You can use the addListItem method in FormEditor class new item to the existing list box field. If you are using the value from datasource (array) use some thing like


// Suppose we have an array X[] which contains some information
int[] x = { 10 };
for (int b = 0; b <= 10; b++)
x[b] = b;

//open the document and create a FormEditor object
FormEditor formEditor = new FormEditor("c:/Temp/Form with Blank Fields.pdf", "c:/Temp/Fields_edited.pdf");
// add an item to existing List Box

FYI: If you need to set the value in a List Box field, please use the following code snippet.

//Open the document and create a Form object like this:
Form form = new Form("Online.pdf", "output.pdf");
//Choose a item from a list field like this (where "period" is the name of ListBox and set its value to 3rd item in X array)
form.setField("period", "" + x[3]);

2) Please try using delListItem in FormEditor class to remove an item from the existing list box field.

3) Regarding your 3rd requirement, I am afraid the feature to remove a Text string from Pdf file, is not yet supported. As a workaround, you can use replaceText in PdfContentEditor class to replace "S2" with blank String.

Please take a look, and in case of any further query, feel free to contact.