Submit form to ASP.NET Web API

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  Re: Submit form to ASP.NET Web API

DynamicPDF CoreSuite for .NET (v10) Forum

 Jun 06 2019 11:04 AM
Using the SubmitAction I am able to add HTML form elements and submit from a PDF to a WEB API service. However, the form data does not appear. Is there a way to do this?

I also tried the JavaScriptAction class, but the PDF documentation states that the submitForm method can only be done when viewing through a browser. I couldn't get it to work either, in any case.
 Jun 06 2019 11:47 AM
To provide a little more context, I am also not able to get the form fields when posting to an ASP.NET web form. Here's my code:

            MergeDocument document = new MergeDocument(MapPath("PurchaseOrderReport.pdf"));

            Label sigLabel = new Label("Enter Initials and Click Approve", 50, 0, 180, 20) { Font = Font.Helvetica, FontSize = 9 };
            TextField iniField = new TextField("InitialText", 50, 25, 150, 20) { BorderStyle = BorderStyle.Solid };
            Button submitButton = new Button("submitButton", 50, 50, 70, 25) { Label = "Approve" };
            TextField resLabel = new TextField("result", 120, 50, 100, 25)
            {
                Font = Font.Helvetica,
                FontSize = 9
            };
            SubmitAction action = new SubmitAction("http://localhost:63475/Approve.aspx", FormExportFormat.HtmlPost);

            submitButton.Action = action;



            AnchorGroup anchorGroup = new AnchorGroup(200, 80, Align.Center, VAlign.Bottom);
            anchorGroup.Add(sigLabel);
            anchorGroup.Add(iniField);
            anchorGroup.Add(submitButton);
            anchorGroup.Add(resLabel);


            Page page = document.Pages[document.Pages.Count - 1];
            page.Elements.Add(anchorGroup);
            document.DrawToWeb("SubmitTest.pdf");
 Jun 06 2019 2:09 PM
Posted by a ceTe Software moderator
Hi,

That should work if you have the right debug port  number. Are you getting any errors?

Thanks,
ceTe Software Support Team
 Jun 06 2019 2:41 PM
There are no errors. I can debug the Aspx page and it does receive the message. But, the form field is not there. There are no form girls at all
 Jun 07 2019 10:01 AM
Posted by a ceTe Software moderator
Hi,

Are you using Chrome as the browser by any chance? We've done some testing  and it looks like there is an issue with submitting the form using Chrome and it's built in PDF viewer. If you download the PDF and view it with Acrobat or use IE with the  Acrobat plug-in, everything works as expected. We'll test some other scenarios as well and see if we can provide more information over the next couple of days.

Thanks,
ceTe Software Support Team
 Jun 13 2019 4:46 PM
I was, in fact, using Chrome. I did some testing and found that the submission only works in IE. Edge did nothing and Acrobat Ready throws an error.

I suspect this is really security related. As I cannot control how users might open the PDF, I'll have to abandon this strategy.

If you are able to get past this problem, I'd love to hear about it as the functionality has a lot of promise.

All times are US Eastern Standard time. The time now is 2:32 AM.