Accept an uploaded PDF in ASP.NET Core, parse it with StiPdfParser, and convert its fields into application data.

Receiving the uploaded PDF. The ASP.NET Core action copies the uploaded document into memory and gives its bytes to StiPdfParser.

Converting the fields. The upload handler in Loading Fields Data from PDF/Controllers/HomeController.cs parses the PDF structure and converts its form data into values the application can display or store:
[HttpPost]
public IActionResult ShowPdfFieldsData(IFormFile pdfFile)
{
    if (pdfFile != null)
        using (var stream = new MemoryStream())
        {
            pdfFile.CopyTo(stream);
            var bytes = stream.ToArray();
            var document = StiPdfParser.Parse(bytes);

            ViewData["pdfData"] = StiPdfImportDocumentHelper.ConvertData(document);
        }

    return View("Index");
}

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.