Cloud
Cloud-Dienstleistung für schnelle und effektive Analyse und Visualisierung von Daten für Ihr Business ohne eigene Applikationen zu erstellen oder zu programmieren.
Generating PDF from Form Submission/Controllers/FormsController.cs creates the finished document and sends its bytes back with the PDF content type:private static StiPdfFormSubmission submission;
private static bool dataChanged = false;
static FormsController()
{
}
[HttpPost]
public IActionResult Action()
{
try
{
var data = JObject.Parse(this.HttpContext.Request.Form["data"]);
var action = data["action"].ToString();
switch (action)
{
case "Initialize":
resultForm = null;
var initData = StiWebForm.Initialize(data, Initialize(data));
return Json(initData.Content);
case "SaveForm":
var form = new StiForm();
form.Load(Convert.FromBase64String(data["form"].ToString()));
form.Save(FormPath);
return Json(form);
case "IsDataChanged":
return Json(dataChanged);
default:
var result = StiWebForm.ProcessRequest(data);
return result.ContentType switch
{
"application/pdf" => new FileContentResult(result.Content as byte[], result.ContentType),
_ => Json(result.Content),
};
}
}
catch (Exception e)
{
return new ContentResult()
{
Content = e.Message,
ContentType = "text/plain"
};
}
}
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;
}