Integrating a Form Component
Наши примеры проектов и шаблоны отчётов помогут Вам разобраться в основах работы с нашими продуктами.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.