How to set a single font for all text during PDF to HTML in C# and .NET
Complete code
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, ".html");
// 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 = "XXXXXXXXXXX";
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);
}
}
}
}
}
Imports System
Imports System.IO
Imports SautinSoft
Namespace Sample
Friend Class Sample
Shared Sub Main(ByVal args() As String)
Dim pdfFile As String = "..\..\..\simple text.pdf"
Dim htmlFile As String = Path.ChangeExtension(pdfFile, ".html")
' 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 = "XXXXXXXXXXX";
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 Class
End Namespace
If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: