This example shows how to generate PDF from form submission.
public IActionResult PostForm()
{
HttpRequest request = this.HttpContext.Request;
string requestBodyString;
try
{
request.EnableBuffering();
byte[] buffer = new byte[Convert.ToInt32(request.ContentLength)];
request.Body.ReadAsync(buffer, 0, buffer.Length);
requestBodyString = Encoding.UTF8.GetString(buffer);
submission = new StiPdfFormSubmission();
submission.ParseXFDF(buffer);
dataChanged = true;
}
finally
{
request.Body.Position = 0;
}
return new ContentResult();
}
public IActionResult GetPdf()
{
var form = new StiForm();
form.Load(FormPath);
if (submission != null)
{
var data = submission.ConvertData(form);
StiFormFillHelper.FillForm(form, data);
}
(form.GetElementByName("Button") as StiButtonElement).Visible = false;
StiPdfExporter exporter = new StiPdfExporter();
var pdf = exporter.ExportForm(form);
dataChanged = false;
return new FileContentResult(pdf, "application/pdf");
}