Convert Aspose PDF Form to PDF file

Hi,
Good Morning all. Below is my requirement. Please help me how to proceed with. We are using Java with Spring framework.

We need to create a online web form on our site. Once the user submits the data, we need to capture the data and write the data to a pdf file, in the same format as the web form, and send the pdf file in an email. So we thought of the below approach.

1) Creating a PDF Form with all the fields in the web form.
2)In my controller using Aspose,populate the PDF form with the data submitted by the user from the web form.
3)Convert the Aspose PDF form to a pdf file and send it in an email.

I am able to do the first two steps successfully. But I am unable to convert the PDF form to a pdf file to send it in an email.

Please let me know how can i proceed.
I am using PDF form jsut as a PDF template. So that we don’t need to recreate the PDF file every time when the user submits the web form.

Any approach on this is highly appreciated.

Thanks,
Pavan.

Hi Pavan,

It looks like you want to make sure that the final PDF file doesn’t contain the editable form fields, rather the field contents. If that is the case, you can use flattenAllFields method to flatten all the PDF form fields.

I hope this helps. If you think it doesn’t satisfy your requirement or you find any further questions, please do let us know.
Regards,

Hi,

Thanks for you quick reply. I am using aspose.pdf.kit.jar and I don’t see flattenAllFields() method in com.aspose.kit.Form class. I downloaded the kit from the aspose site only. Please let me know if I am missing something.

Thanks,
Pavan.

Hi,

I found the method allFlatten() in the Form class. I hope it is same as flattenAllFields() method. But how can I convert the PDF Form to a PDF File? Can you please let me know how allFlatten() method helps me in converting a ASPOSE PDF Form to a PDF File object.

Thanks,
Pavan.

Hi Pavan,

First of all, I would like to share with you that allFlatten method is now obsolete; please download the latest version and use flattenAllFields method.

Secondly, flattenAllFields method allows you to flatten the form fields in such a way that they become the part of the PDF content instead of looking as form fields.

Lastly, as I understand, you wanted to make the PDF form look like the normal PDF i.e. the fields become part of the actual PDF content. If this is not the case then please elaborate what you mean by converting Aspose PDF Form to PDF object. If you could share a sample that would be helpful.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hi,
Thanks a lot for your suggestions.

I wanted to make the PDF form look like the normal PDF i.e. the fields become part of the actual PDF content. Then send that PDF file in an email.

So, will flattenAllFields() method create a pdf file by copying all the contents from the PDF form . If so, will the PDF form in my file system gets converted to a PDF file.

Can you please elaborate on how this works?

Thanks,
Pavan.


Hi Pavan,

Yes, you're right; flattenAllFields method of the Form class creates a copy of the original PDF form and saves the new copy with all the fields flattened. Please try the following code snippet at your end for proof of concept:

//add form fields in an existing PDF file
FormEditor formEditor = new FormEditor("input.pdf","pdfform.pdf");
formEditor.addField(FormEditor.FLDTYP_TXTFLD, "text1", "This is a line", 1, new Rectangle(100,600,200,50));
formEditor.close();

//flatten the PDF form fields and save as output PDF file
Form form = new Form("pdfform.pdf", "flattened.pdf");
form.flattenAllFields();
form.save();

I hope you've got the idea. If you find any further questions, please do let us know.

Regards,

Hi,

I created a PDF form using the Adobe LiveCycle Designer ES 8.2. Below is the code to populated the PDF form.

Form form= new Form(outputPath+“inputform.pdf”,outputPath+“flatten.pdf”);
form.setField(“pcoName”, velClaim.getPcoName());
form.setField(“refNumber”, velClaim.getRefNumber());
form.flattenAllFields();
form.save();

But form.save() is throwing the nullpointer exception. Below is the stack trace.
java.lang.NullPointerException
at com.aspose.pdf.kit.Form.close(Unknown Source)
Can I use the the PDF form created by Adobe LiveCycle Designer or do i need to create the complete the form only with FormEditor. I also tried the code snippet you sent. But it also throwing the null pointer exception while closing the form editor.
java.lang.NullPointerException
at com.aspose.pdf.kit.FormEditor.close(Unknown Source)

I am attaching the PDF form i created using the Adobe LiveCycle Designer. Please let me know if I am missing anything.

Thanks,
Pavan.

Hi Pavan,

I have tested this issue using the latest version at my end, but couldn’t notice any such problem. Can you please make sure that you’re using the latest version as well? If you still find the same issue at your end then please share some more details like the OS, JDK version and the actual values being stored in the fields. We’ll test the issue using your particular scenario and update you accordingly.

Moreove, I would like to share that you can originally create the forms or PDF files using any tool and Aspose.Pdf.Kit would be able to process it; sometimes, the issues might be caused due to the particular contents or structure of the PDF file or some other such reason; nevertheless, our team keeps working on such scenarios and we try to provide the fixes the earliest possible.

Please try the latest version and share the details with us, so we could further help you out.

We’re sorry for the inconvenience.

Regards,

Hi,

I am using aspose-pdf-kit-3.3.0.jar file. I downloaded the “aspose-pdf-kit-3.3.0-java.zip” file from the downloads section. We are using JDK 1.4(jdk142_05) and windows 2000. We deployed the application in weblogic 8.1. I am facing the same problem while calling form.save(). I populated some dummy values into the form fields.
Form form = new Form(outputPath+“inputform.pdf”,outputPath+“flatten.pdf”);
form.setField(“pcoName”, “testpco”);
form.setField(“refNumber”, “123”);
form.flattenAllFields();
form.save();

“flatten.pdf” is generated in the output folder. But it is corrupted. I am unable to open it.
Please let me know if I am missing anything.

Thanks,
Pavan.

Hi Pavan,

I have again tested this issue using JDK 1.4 in a regular Java application and it worked fine. However, as you mentioned that this issue occurs on Weblogic server, so I'll test the issue on that and update you accordingly the earliest possible.

We're sorry for the inconvenience and looking forward to help you out.

Regards,

Hi Pavan,

I have reproduced this problem on Weblogic Server; it doesn’t occur in the local Java application. I have logged this issue as PDFKITJAVA-19799 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Hi,

Can you please let me know the expected delivery date for this issue.

Thanks,
Pavan.

Hi Pavan,

I’m sorry to share with you that at the moment we’re unable to share the ETA of this issue. Our team is looking into this problem and we’ll inform you about the estimate once we get a clear idea.

We’re sorry for the inconvenience.
Regards,

The issues you have found earlier (filed as 19799) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.