Saves all pages of the PDF document to HTML file

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 6.6.9.7 (6.6.9.7)

Syntax

      
 C#  Visual Basic 
public int ToHtml(
	string fileName
)
Public Function ToHtml ( _
	fileName As String _
) As Integer

Parameters

fileName
String
Path to the HTML file

Return Value

0 - saving successfully
2 - can't create output file, check the output path
3 - saving failed, email to support@sautinsoft.com

Examples

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

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            string pdfFile = @"..\..\..\..\..\simple text.pdf";
            string htmlFile = Path.ChangeExtension(pdfFile, ".htm");

            // Convert PDF file to HTML file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // Path (must exist) to a directory to store images after converting. Notice also to the property "ImageSubFolder".
            f.HtmlOptions.ImageFolder = Path.GetDirectoryName(pdfFile);
            // A folder (will be created by the component) without any drive letters, only the folder as "myfolder".
            f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile));
            // We recommend to use PNG type for storing images.
            f.HtmlOptions.ImageType = PdfFocus.CHtmlOptions.eHtmlImageType.Png;
            // How to store images: Inside HTML document as base64 images or as linked separate image files.
            f.HtmlOptions.IncludeImageInHtml = false;
            // Set <title>...</title>
            f.HtmlOptions.Title = "Simple text";

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

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                int result = f.ToHtml(htmlFile);

                // Show resulted HTML document in a browser.
                if (result==0)
                {
                    System.Diagnostics.Process.Start(htmlFile);
                }
            }
        }
    }
}
CopyHow to convert PDF file to HTML file using VB.Net
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft

Module Sample

    Sub Main()
        Dim pdfFile As String = "..\..\..\..\simple text.pdf"
        Dim htmlFile As String = Path.ChangeExtension(pdfFile, ".htm")

        ' Convert PDF file to HTML file
        Dim f As New SautinSoft.PdfFocus()

        ' Path (must exist) to a directory to store images after converting. Notice also to the property "ImageSubFolder".
        f.HtmlOptions.ImageFolder = Path.GetDirectoryName(pdfFile)
        ' A folder (will be created by the component) without any drive letters, only the folder as "myfolder".
        f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile))
        ' We recommend to use PNG type for storing images.
        f.HtmlOptions.ImageType = PdfFocus.CHtmlOptions.eHtmlImageType.Png
        ' How to store images: Inside HTML document as base64 images or as linked separate image files.
        f.HtmlOptions.IncludeImageInHtml = False
        ' Set <title>...</title>
        f.HtmlOptions.Title = "Simple text"

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


        f.OpenPdf(pdfFile)

        If f.PageCount > 0 Then
            Dim result As Integer = f.ToHtml(htmlFile)

            ' Show resulted HTML document in a browser.
            If result = 0 Then
                System.Diagnostics.Process.Start(htmlFile)
            End If
        End If
    End Sub
End Module

See Also