Saves a specific PDF page or diapason of pages 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,
	int fromPage,
	int toPage
)
Public Function ToHtml ( _
	fileName As String, _
	fromPage As Integer, _
	toPage As Integer _
) As Integer

Parameters

fileName
String
Path to the HTML file
fromPage
Int32
The starting page for exporting to HTML
toPage
Int32
The ending page for exporting to HTML

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 set a single font for all text during PDF to HTML converting in C#
using System;
using System.IO;
using SautinSoft;

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

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

            // Let's change all text to Verdana 8pt.
            f.HtmlOptions.SingleFontFamily = "Verdana";
            f.HtmlOptions.SingleFontSize = 8;


            // 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 from = 1;
                int to = (3 > f.PageCount) ? f.PageCount : 3;

                int result = f.ToHtml(htmlFile, from, to);

                // Show resulted HTML document in a browser.
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(htmlFile);
                }
            }
        }
    }
}
CopyHow to set a single font for all text during PDF to HTML converting in VB.Net
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft

Module Sample

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

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

        ' Let's change all text to Verdana 8pt.
        f.HtmlOptions.SingleFontFamily = "Verdana"
        f.HtmlOptions.SingleFontSize = 8


        ' 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 [from] As Integer = 1
            Dim [to] As Integer = If(3 > f.PageCount, f.PageCount, 3)

            Dim result As Integer = f.ToHtml(htmlFile, [from], [to])


            ' 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