Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

html to pdf c#

using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using System.IO;

namespace HTML_File_To_PDF
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize the HTML to PDF converter with the Blink rendering engine.
            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);

            BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

            //Set the BlinkBinaries folder path.
            blinkConverterSettings.BlinkPath = @"../../../../../BlinkBinariesWindows/";

            //Assign Blink converter settings to HTML converter.
            htmlConverter.ConverterSettings = blinkConverterSettings;

            //Convert HTML string to PDF.
            PdfDocument document = htmlConverter.Convert("<h1>Hello world</h1>","");

            FileStream fileStream = new FileStream("Sample.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);

            //Save and close the PDF document .
            document.Save(fileStream);
            document.Close(true);
        }
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #html #pdf
ADD COMMENT
Topic
Name
3+4 =