PDF FromHTML in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source

The sample demonstrates how to convert HTML to PDF document.

Download FromHTML.pdf

using System;
using Spire.Pdf;

namespace FromHTML
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            //Create a pdf document.
            PdfDocument doc = new PdfDocument();

            String url = "http://www.e-iceblue.com/";
            doc.LoadFromHTML(url, false, true, true);

            //Save pdf file.
            doc.SaveToFile("FromHTML.pdf");
            doc.Close();

            //Launching the Pdf file.
            System.Diagnostics.Process.Start("FromHTML.pdf");
        }

    }
}

Imports Spire.Pdf

Namespace FromHTML
    Friend Class Program
         _
        Shared Sub Main(ByVal args() As String)
            'Create a pdf document.
            Dim doc As New PdfDocument()

            Dim url As String = "http://www.e-iceblue.com/"
            doc.LoadFromHTML(url, False, True, True)

            'Save pdf file.
            doc.SaveToFile("FromHTML.pdf")
            doc.Close()

            'Launching the Pdf file.
            Process.Start("FromHTML.pdf")
        End Sub

    End Class
End Namespace