PdfFocusToHtml(String) Method |
Saves all pages of the PDF document to HTML file
Namespace: SautinSoftAssembly: SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 2024.8.6
Syntax public int ToHtml(
string fileName
)
Public Function ToHtml (
fileName As String
) As Integer
Parameters
- fileName String
- Path to the HTML file
Return Value
Int32
0 - saving successfully
2 - can't create output file, check the output path
3 - saving failed, email to
support@sautinsoft.comExample How 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 = Path.GetFullPath(@"..\..\..\simple text.pdf");
string htmlFile = "Result.html";
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.HtmlOptions.ImageFolder = Path.GetDirectoryName(htmlFile);
f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile));
f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Auto;
f.HtmlOptions.IncludeImageInHtml = false;
f.HtmlOptions.Title = String.Format("This HTML was converted from {0}.", Path.GetFileName(pdfFile));
f.OpenPdf(pdfFile);
if (f.PageCount > 0)
{
int res = f.ToHtml(htmlFile);
if (res == 0)
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFile) { UseShellExecute = true });
}
}
}
}
How to convert PDF file to HTML file using VB.Net
Imports System
Imports System.IO
Imports SautinSoft
Namespace Sample
Friend Class Sample
Shared Sub Main(ByVal args() As String)
Dim pdfFile As String = Path.GetFullPath("..\..\..\simple text.pdf")
Dim htmlFile As String = "Result.html"
Dim f As New SautinSoft.PdfFocus()
f.HtmlOptions.ImageFolder = Path.GetDirectoryName(htmlFile)
f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile))
f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Auto
f.HtmlOptions.IncludeImageInHtml = False
f.HtmlOptions.Title = String.Format("This HTML was converted from {0}.", Path.GetFileName(pdfFile))
f.OpenPdf(pdfFile)
If f.PageCount > 0 Then
Dim res As Integer = f.ToHtml(htmlFile)
If res = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(htmlFile) With {.UseShellExecute = True})
End If
End If
End Sub
End Class
End Namespace
See Also