Convert from HTML to PDF in ASP.NET Core with a Free 3rd Party Library

Html to Pdf Conversion is now available for .NET Core. SelectPdf offers a Community Edition (FREE) of the powerful Html To Pdf Converter for .NET Core that can be found in the full featured pdf library.

C# (1.6 MB)
 
 
 
 
 
4.5 Star
(2)
1,808 times
Add to favorites
5/10/2019
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
using System;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Primitives;
using System.Collections.Generic;

namespace SelectPdf.Samples.Pages
{
    [IgnoreAntiforgeryToken(Order = 1001)]
    public class ViewHttpPostDataModel : PageModel
    {
        public void OnGet()
        {
        }

        public void OnPost()
        {
            StringBuilder output = new StringBuilder();
            output.Append("<br/>Request method: " +
                Request.Method + "<br/>");

            // Parse POST form fields collection.
            foreach (KeyValuePair<string, StringValues> element in Request.Form)
            {
                output.Append("Name: " + element.Key + "<br/>");

                // Get all values under this key.
                String[] values = element.Value.ToArray();
                for (int j = 0; j < values.Length; j++)
                {
                    output.Append("Value: " + values[j] + "<br/>");
                }
                output.Append("<br/>");

            }

            ViewData.Add("PostDataValue", output.ToString());

        }
    }
}