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

Free Support Forum - aspose.com

How to flatten a PDF form when user saves

Hello,

I am evaluating Aspose.PDF.Kit, using VB.Net.

I am trying to develop a web app where the user can bring up an already created fill-able PDF. That part is easy, using a simple link to the PDF document. I would like to give the user a SAVE button (somewhere) which they can click after they've completed the form. When they click that save button, I need to save a copy of the form, with their information filled in, back to the web server. I believe this is known as "flattening" the document; correct?

There are some concepts which I am not understanding though -- where should I place this SAVE button? If I make it part of the fill-able PDF, can I write a .Net event handler somewhere that can do the flattening when that button is clicked? That doesn't seem do-able.

I'm not understanding this because the PDF file "takes over" the browser window. For that same reason, I can not put the SAVE buton on the web page (HTML) anywhere. I suppose I can launch the PDF document in a separate browser window (using target="_blank" in the original HTML link (a href) tag), but, still, can the parent browser window then grab hold of the PDF file in that sceanrio?

I need some guidance here because I am missing some basic concepts I think.

Thanks,

Charlie

Hi Charlie,

First of all, I would like to share with you that ‘Flattening’ here means to flatten the PDF form fields; which allows you to make the field contents the part of the actual text in the PDF, that is the fields are no more editable and the contents look just like the normal text in the PDF file. You can use FlattenAllFields method to achieve that.

Secondly, as far as your requirement is concerned, I would like to inform you that you can’t directly send the filled PDF file to the server; as the file is downloaded on the client end and the only way is to upload the filled PDF file to the server using some file upload feature of the .NET Framework.

However, Aspose.Pdf.Kit can help you in two different ways (if you like the scenarios):

1. If you just want to post the filled PDF form data back to the server, you can find this topic helpful. In this way, you can post your data to a web page and process it on the server end.


2. If you want to finally fill and save the PDF file itself on the server then you can give a web form to the users, which is posted by the user after filling it and on the server end you can take this input and save the values to the PDF form using Form.FillField method.

I hope this helps. If you think I haven’t understood your requirement clearly, or you have some more questions, please do let us know.
Regards,



Thanks for the information. It makes sense. When I used Acrobat Pro 9.0 to embed the SUBMIT button in my AcroForm it does not work. That is, it does post to my specified URL but no form fields are getting posted. I then removed the button via Acrobat 9 Pro and, instead, added the buton via Aspose.Pdf.Kit.

Now, when I open the PDF document, the button is there and when I roll the mouse over it I can see the correct URL to which the form is supposed to get posted. But when I click the submit button nothing happens. The button changes color as if it is acknowledging my click, but it does not post to the specified URL and nothing happens (the Acroform remains on the screen).

I have tried this with "Extend Features in Adobe Reader" both ON and OFF via Acrobat Pro 9, but the behavior is the same.

I must be missing something obvious -- why can't I get the acroform to post to a specified URL? Any ideas? I'd prefer to add the button at design time via Acrobat Pro 9, but I did see in the forum where someone else could not get that to work either and I don't think he ever figured out why. That's why I'm tring to add the button using Aspose.Pdf.Kit, although that doesn't even bring up the referenced post URL page when the submit button is clicked.

I have attached the acroform which contains the submit button as embedded by Aspose.Pdf.Kit.

Thanks

Hi Charlie,

Please share the input PDF file along with the code snippet you used to add the button and set the submit URL. We’ll try to reproduce and test the issue at our end and you’ll be updated accordingly.

Moreover, please share the details regarding the file in which you’re trying to add the button and submit URL using Acrobat Pro. Was this file created using Aspose.Pdf.Kit for .NET? If it was created using .NET and you’re trying to add the button and submit URL into this file then please share that PDF file as well.

We’re sorry for the inconvenience.
Regards,

Hello,

I appreciate your help!

Let's start with the latest PDF file I created. This one is attached. I created it using the Designer inside Acrobat Pro 9. For this one, the HTTP Submit button was added inside Designer as well.

Now when you click the submit button it behaves strangely -- bringing up a temp HTML file instead of just calling the URL attached to the submit button.

Below is the code behind inside aa_form_handler.aspx.vb. I'm still nto seeing any form elements posted.

EDIT -- I see now that there are realy two methods for creating forms - directly inside Acrobat Pro and inside Adoben LiveCyce Designer. Should I stay with one or the other? I've tried using both and can't get a form to post properly with either, but I'm wondering if I should stay away from LiveCycle designer for my purposes.

Thanks again,

Charlie

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim form As New Aspose.Pdf.Kit.Form("M:\WebSites\SimpleChoiceManager\documents\aa_test_fillable.pdf")

Dim field_name As String

'Get field names

Dim fieldNames() As String = form.FieldsNames

OutputDiv.InnerHtml = "Form fields in document on the server:
"

For Each field_name In form.FieldsNames

OutputDiv.InnerHtml = OutputDiv.InnerHtml & field_name & "
"

Next

OutputDiv.InnerHtml = OutputDiv.InnerHtml & field_name & "
Form fields and values that got posted:
"

OutputDiv.InnerHtml = OutputDiv.InnerHtml & "Number = " & Request.Form.Count

For Each field_name In Request.Form

OutputDiv.InnerHtml = OutputDiv.InnerHtml & "Name: " & field_name & "   Value: " & Request.Form.[Get](field_name) & "
"

Next

form = Nothing

End Sub

Hi Charlie,

As I can see, you’re not only creating this form with the Acrobat Pro. but also adding the button and submit URL using the same. I can’t see any involvement of the Aspose.Pdf.Kit in this scenario and I’m afraid the issue is related to Acrobat Pro. itself. Can you please post this particular issue in Acrobat related forums? I’m sorry, I can only help you regarding the Aspose.Pdf.Kit related issues.

We’re sorry for the inconvenience.
Regards,

Hello,

Should I assume then that for any form created with Adobe Acrobat Pro I will not be able to integrate with the features of Aspose.Pdf.Kit? Are you saying that the Aspose.Pdf.Kit really only works smoothly with forms that were created in Aspose.Pdf.Kit? Have you been able to get the acroform form field posting to work at all with a form that was created with Adobe Acrobat Pro 9.0? Have you seen that work at all? I don't want to waste any more of my time if what I'm trying to do is not really do-able.

Thanks,

Charlie

Hi Charlie,

The PDF forms created with Acrobat work fine when manipulated with Aspose.Pdf.Kit; however, in this particular scenario, I’m unable to see any involvement of the Aspose.Pdf.Kit i.e. the form is fully created with Acrobat and you’re trying to submit it. Of course, in that case it could possibly be caused by the Acrobat Pro. itself.

If I haven’t understood the situation clearly, please help me understand it.

We’re very sorry for the inconvenience.
Regards,



Hi Shahzad,

You have accurately assessed the situation. Are there any tips you can give me for creating the form in Acrobat? The form I created is about as simple as it gets and still it doesn't work. Can you send me a sample form that you created in Acrobat that will work perhaps? Otherwise, I just don't know what to do differently in Acrobat.

Also -- do you know -- does it matter if I create the form in Acrobat itself versus Adobe LiveCycle Designer?

Thanks,

Charlie

Hi Charlie,

As far as creating form using Adobe Acrobat or LiveCycle is concerned, I would recommend you to post your query in the Adobe Forums.

Moreover, I would like to add that you can also use Aspose.Pdf.Kit for .NET to create PDF forms and set submit URL. You can find the help topics on this link. Also, you can find the details about creating a simple PDF form with a submit button and then receiving the posted form’s values on a web page in the following article: Posting AcroForm data to an external web page

I hope this helps. If you have any further questions, please do let us know.
Regards,