Integrating a Form Component
Our sample projects and report templates can help you learn the basics of working with our products.Stimulsoft PDF Forms provides an Angular component for editing and filling forms in the browser, backed by a single ASP.NET Core action.
Handle form requests in the controller.
How it works. A single action multiplexes the form component's requests, so the Angular form talks to one endpoint for setup, editing and PDF output.
Handle form requests in the controller.
[HttpPost]
public IActionResult Action()
{
var data = JObject.Parse(this.HttpContext.Request.Form["data"]);
var action = data["action"].ToString();
switch (action)
{
case "Initialize":
var initData = StiWebForm.Initialize(data, null);
return Json(initData.Content);
default:
var result = StiWebForm.ProcessRequest(data);
return result.ContentType switch
{
"application/pdf" => new FileContentResult(result.Content as byte[], result.ContentType),
_ => Json(result.Content),
};
}
}StiWebForm.Initialize(data, options)— sets up the form component on first request.StiWebForm.ProcessRequest(data)— handles subsequent actions; a PDF result is streamed back as a file.
How it works. A single action multiplexes the form component's requests, so the Angular form talks to one endpoint for setup, editing and PDF output.