Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

convert html to pdf c#

var htmlContent = String.Format("<body>Hello world: {0}</body>", DateTime.Now);
var pdfBytes = (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(htmlContent);
//https://www.nrecosite.com/doc/NReco.PdfGenerator/
Comment

c# html to pdf

// PM > Install-Package NReco.PdfGenerator

Create HtmltoPdf(){
   if (System.IO.File.Exists("HTMLFile.html"))
    {
        System.IO.File.Delete("HTMLFile.html");
    }

    System.IO.File.WriteAllText("HTMLFile.html", html);
    var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
    if (System.IO.File.Exists("export.pdf"))
    {
        System.IO.File.Delete("export.pdf");
    }

    htmlToPdf.GeneratePdfFromFile("HTMLFile.html", null, "export.pdf");
 }
Comment

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);
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# remove duplicates from list 
Csharp :: winforms how to check for enter key 
Csharp :: array reduce c# 
Csharp :: c# loop through dictionary 
Csharp :: remove force unity 
Csharp :: Reverse Coding Challenge 1 
Csharp :: what is void onmousedown() 
Csharp :: c# string console readline array 
Csharp :: decrease image size C# 
Csharp :: Get enum value from string or int 
Csharp :: wasd code for unity 
Csharp :: unity making homing missile 
Csharp :: how to make a 3d object do something when clicked on 
Csharp :: C# actions 
Csharp :: how to close another app in system with c# 
Csharp :: C# extract all of a property from a list of objcets 
Csharp :: c# add key value pair to dictionary 
Csharp :: visual studio c# mark class deprecated 
Csharp :: reverse linked list 
Csharp :: XMLWriter write xml C# 
Csharp :: quaternion rotation unity 
Csharp :: c# add list to list 
Csharp :: dynamically add rows to datagridview c# 
Csharp :: vb.net center form in screen 
Csharp :: hide numericUpDown arrows 
Csharp :: c# windows forms cancel event 
Csharp :: unity c# find object position in array 
Csharp :: photon2 addcalbacktarget 
Csharp :: linq from list c# 
Csharp :: winform fixed size 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =