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

Free Support Forum - aspose.com

Post PDF form field data to ASP.NET webmethod

Hello,

I have a pdf that was created using Acrobat Pro DC. This pdf has many form fields on it. I am looking for a way to submit the form field data back to an ASP.NET Webmethod behind the scenes when a button is clicked. The user could then continue filling out the form, saving as many times as they want. This would be a lot like using ajax to post data to a webmethod.

Currently I am converting the pdf into a memorystream and then adding the submit button with the following code:

Dim doc As New Aspose.Pdf.Document(pdfStream)
Dim formEditor As New Aspose.Pdf.Facades.FormEditor(doc)
formEditor.AddSubmitBtn("btnSave", 1, "Save", buttonAction, 400, 20, 500, 50)
formEditor.Save(pdfStream)

buttonAction would be something like "https://localhost/somepage.aspx/webmethod"

This is the type of webmethod that is being called:

Public Shared Function SavePDFData() As String
Try
'Save data to database
Return "Success"
Catch ex As Exception
Return "Failed"
End Try

End Function

What happens now is that when the button is clicked the pdf does in fact post the data to the page (I am using Fiddler to see this) but I don't see any indication that it ever got to the webmethod on the page but instead tries to open "https://localhost/somepage.aspx/webmethod".

I'm not sold on using a webmethod for this so if there is a better way I am more than willing to try it as long as the end result is not redirecting to another page.

Hello,



I have a pdf that was created using Acrobat Pro DC. This pdf has many form fields on it. I am looking for a way to “silently” submit the form field data back to an ASP.NET Webmethod. By silently I mean when you click the submit button it sends the form data to the webmethod behind the scenes.



Currently I am converting the pdf into a memorystream and then adding the submit button with the following code:



Dim doc As New Aspose.Pdf.Document(pdfStream)

Dim formEditor As New Aspose.Pdf.Facades.FormEditor(doc)

formEditor.AddSubmitBtn(“btnSave”, 1, “Save”, buttonAction, 400, 20, 500, 50)

formEditor.Save(pdfStream)

Hi John,


Thanks for contacting support.

SetSubmitUrl method allows you to set the submit button’s URL in a PDF file. This is the URL where the data is posted when the submit button is clicked. SetBumitUrl method required the name of the submit button field and the URL. This method is provided by FormEditor class. You can check documentation link Set Submit Button URL in existing PDF document for sample example.

If you still face any issue, please feel free to contact us.

Best Regards,

Thank you for responding Fahad.


I tried using the SetSubmitURL and I still get the same result. If this helps the PDF is opened in a browser as opposed to Adobe Reader. When clicking the button it appears to post the data to the specified URL but instead the PDF is then redirected to the URL.

Is there a way to post the pdf data without it wanting to open a new window?

Thanks!

Hi John,


p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000; min-height: 14.0px} span.s1 {font-kerning: none}

I will appreciate if you please share your sample web project. It will help us to understand your requirement exactly and address it accordingly.


We are sorry for the inconvenience.


Best Regards,

Hi John,


Thanks for sharing the details.

In order to accomplish your requirements, please try following instructions specified over Posting AcroForm data to an external web page