PdfFocusCHtmlOptionsTitle Property |
Sets the title for the HTML document. Default value: "Untitled document".
Namespace: SautinSoftAssembly: SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 2024.11.11
Syntax public string Title { get; set; }
Public Property Title As String
Get
Set
Property Value
StringExample How to convert PDF to separate HTML pages in C#
using System;
using System.IO;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
string pdfFile = Path.GetFullPath(@"..\..\..\simple text.pdf");
DirectoryInfo htmlDir = new DirectoryInfo("htmls");
if (!htmlDir.Exists)
htmlDir.Create();
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.HtmlOptions.IncludeImageInHtml = false;
f.HtmlOptions.ImageFolder = htmlDir.FullName;
f.OpenPdf(pdfFile);
if (f.PageCount > 0)
{
for (int page = 1; page <= f.PageCount; page++)
{
f.HtmlOptions.Title = $"Page {page}";
f.HtmlOptions.ImageSubFolder = String.Format("page{0}_images", page);
string htmlString = f.ToHtml(page, page);
string htmlFile = Path.Combine(htmlDir.FullName, $"Page{page}.html");
File.WriteAllText(htmlFile, htmlString);
if (page == 1 || page == f.PageCount)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFile) { UseShellExecute = true });
}
}
}
}
}
}
How to convert PDF to separate HTML pages in VB.Net
Imports System
Imports System.IO
Namespace Sample
Friend Class Sample
Shared Sub Main(ByVal args() As String)
Dim pdfFile As String = Path.GetFullPath("..\..\..\simple text.pdf")
Dim htmlDir As New DirectoryInfo("htmls")
If Not htmlDir.Exists Then
htmlDir.Create()
End If
Dim f As New SautinSoft.PdfFocus()
f.HtmlOptions.IncludeImageInHtml = False
f.HtmlOptions.ImageFolder = htmlDir.FullName
f.OpenPdf(pdfFile)
If f.PageCount > 0 Then
For page As Integer = 1 To f.PageCount
f.HtmlOptions.Title = $"Page {page}"
f.HtmlOptions.ImageSubFolder = String.Format("page{0}_images", page)
Dim htmlString As String = f.ToHtml(page, page)
Dim htmlFile As String = Path.Combine(htmlDir.FullName, $"Page{page}.html")
File.WriteAllText(htmlFile, htmlString)
If page = 1 OrElse page = f.PageCount Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(htmlFile) With {.UseShellExecute = True})
End If
Next page
End If
End Sub
End Class
End Namespace
See Also