Converts HTML file or URL to PDF file. Output file will be overwritten.

Namespace:  SautinSoft
Assembly:  PdfMetamorphosis (in PdfMetamorphosis.dll) Version: 6.7.12.19

Syntax

      
 C#  Visual Basic 
public int HtmlToPdfConvertFile(
	string inputFileName,
	string outputFileName
)
Public Function HtmlToPdfConvertFile ( _
	inputFileName As String, _
	outputFileName As String _
) As Integer

Parameters

inputFileName
String
Path to local HTML file or URL
outputFileName
String
Local path to output PDF file

Return Value

0 - converting successfully
1 - can't open input HTML file, check the input path
2 - can't create output file, check the output path
3 - converting failed

Remarks

Examples

CopyHow to convert HTML file to PDF file in C#
using System;
using System.IO;
using System.Collections;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            //After purchasing the license, please insert your serial number here to activate the component
            //p.Serial = "XXXXXXXXXXX";

            //specify some options
            p.PageSettings.Size.A4();
            p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape;

            p.PageSettings.Numbering.Text = "Page {page} of {numpages}";

            if (p != null)
            {
                string inputFile = @"..\..\..\..\..\test.htm";
                string outputFile = @"..\..\..\..\..\test.pdf";

                int result = p.HtmlToPdfConvertFile(inputFile, outputFile);

                if (result == 0)
                {
                    System.Console.WriteLine("Converted successfully!");
                    System.Diagnostics.Process.Start(outputFile);
                }
                else
                {
                    System.Console.WriteLine("Converting Error!");
                }
            }
        }
    }
}
CopyHow to convert HTML file to PDF file in VB.Net
Imports System
Imports System.IO
Imports System.Collections

Namespace Sample
    Friend Class Test

        Shared Sub Main(ByVal args() As String)
            Dim p As New SautinSoft.PdfMetamorphosis()

            'After purchasing the license, please insert your serial number here to activate the component
            'p.Serial = "XXXXXXXXXXX";


            'specify some options
            p.PageSettings.Size.A4()
            p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape

            p.PageSettings.Numbering.Text = "Page {page} of {numpages}"

            If p IsNot Nothing Then
                Dim inputFile As String = "..\..\..\..\..\test.htm"
                Dim outputFile As String = "..\..\..\..\..\test.pdf"

                Dim result As Integer = p.HtmlToPdfConvertFile(inputFile, outputFile)

                If result = 0 Then
                    System.Console.WriteLine("Converted successfully!")
                    System.Diagnostics.Process.Start(outputFile)
                Else
                    System.Console.WriteLine("Converting Error!")
                End If
            End If
        End Sub
    End Class
End Namespace

See Also