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

Free Support Forum - aspose.com

formEditor.addField doesn't work

Hi Aspose,

I am trying out the pdf kit for Java and it works perfectly but there is 1 things that doesn’t work.

I have created a pdf in Adobe lifecycle designer. I say it as a dynamic pdf. I then use your software to load the pdf. I can set field values and set the submit url of a submit button. I then try to add text fields using the example code. When I vew the edited pdf I can see the fields that have been filled, the submit url has changed but no text fields. It seams as if your example code doesnt work. The code I use is:

formEditor.addField(FormEditor.FLDTYP_BTNFLD,“button1”,“ButtonName”,1,new Rectangle(50, 50, 100, 20));
formEditor.addField(FormEditor.FLDTYP_TXTFLD, “text1”,“TextName”, 1, new Rectangle(200, 50, 100, 20));

formEditor.setItems(new String[]{“123”,“abc”,“456”});
formEditor.addField(FormEditor.FLDTYP_COMBOBOX, “combobox1”,"", 1, new Rectangle(50, 100, 100, 40));

The fields that were already on the pdf are filled and the submit url has changed so I am seeing the altered pdf but the newly fields aren’t on the pdf.

Any advice,
Martyn Hiemstra

Hi Martyn,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

I think there are some features in adobe livecycle designer 8.0 which are not supported by Aspose.Pdf.Kit and I am not sure which version you are using. Please share the version information, Code and the Pdf template. We will investigate this issue and reply to you soon.

We apologize for your inconvenience.

Hi,

I have attached the pdf template to this forum message. I designed the pdf in Adobe LiveCycle Designer ES 8.1

The code I use to add the hidden field is this:


Hi,

I have attached the pdf template to this forum message. I designed the pdf in Adobe LiveCycle Designer ES 8.1

The code I use to add the fields can be found in pdf.txt. I tried putting the code in this forum message vut it was deleted without any warning so I put it in a text file as an attachment.

Martyn


Dear Martyn,

Thanks for considering Aspose.Pdf.Kit for Java, and also thanks for the resources you provided.

As you known, there are two kinds of Forms, namely AcroForm and XfaForm. Unfortunately, FormEditor only works for AcroForm fields. However, the PDF template in the attachment belongs to XfaForm, which means Kit cannot add a field in such a PDF document.

The support of adding XfaForm fields is in the plan, but it won't be finished in a short time. Sorry for the inconvenience.

Best regards.

Dear Aspose,

Thanks you for your quick response. Maybe you can supply us with an alternative solution to my problem.

We want to supply pdf’s to our customers. They are allowed to fill in the editable fields. Each pdf will have a submit button on it and it will allow users to submit the altered values by xml (A submit button can send the field values by xml to a remote url). We will receive the xml on our server. Since we have multiple customers, we want to filter out which customer send the xml and we want to make sure that this information information can not be tampered with. Have you got a solution for this problem?

Thanks
Martyn Hiemstra

Hello Martyn,

You can create a Pdf file continuing form fields using Aspose.Pdf. For more information please visit Manipulating Form Fields

But according to your requirement, you want to allow the user to fill the form and submit it back through web, you need to use Aspose.Pdf.Kit, which contains a class named FormEditor, and you can use AddSubmitBtn method and you can specify the url to which it submits the form data. You can also submit the form values through email.

In order to export the form values into XML, Please visit Import and Export into XML. Than you can submit the xml file to remote url.

Actually FormEditor.AddSubmitBtn() can add a submit button to existing PDF template, e.g.:<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” />

FormEditor formeditor = new FormEditor( "addSubmitBtn.6.in.pdf", "out.pdf");
String mailurl = "mailto:abc@aspose.com";
formeditor.AddSubmitBtn("SubmitBtn1", 1, "Mail to Me",mailurl, 50, 760, 130, 778);
String httpurl = "";
formeditor.AddSubmitBtn("SubmitBtn2", 1, "Submit",httpurl, 250, 760, 330, 778);
formeditor.Save();

While FormEditor.SetSubmitUrl() can change the submit url of a submit button, e.g.:

FormEditor formeditor = new FormEditor("input.pdf", "output.pdf");
formeditor.SetSubmitUrl("SubmitBtn1", "[www.aspose.com](http://www.aspose.com/)");
formeditor.SetSubmitUrl("SubmitBtn2", "mailto:abc@aspose.com");
formeditor.Save();

I am not sure whether they would fulfill your requirement completely, please test it.

Please visit Aspose.Pdf vs. Aspose.Pdf.Kit regarding information to distinguish among both the products.