Click or drag to resize

PdfFocusCHtmlOptions Class

Allows to specify various properties for HTML document: title, how to store images, inline CSS and so forth.
Inheritance Hierarchy
SystemObject
  SautinSoftPdfFocusCHtmlOptions

Namespace: SautinSoft
Assembly: SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 2024.11.11
Syntax
public class CHtmlOptions

The PdfFocusCHtmlOptions type exposes the following members.

Constructors
 NameDescription
Public methodCode examplePdfFocusCHtmlOptions The default constructor for the CHtmlOptions class.
Top
Properties
 NameDescription
Public propertyDetectTables Gets or sets a value to parse and recreate tables. Default value: false.
Public propertyCode exampleImageFileName Gets or sets a template name for images. Default value: "image".
Public propertyCode exampleImageFolder Gets or sets a path to a directory to store images after converting. Notice also to the property "ImageSubFolder". Default value: "".
Public propertyCode exampleImageNumStart The starting number for naming images in the HTML document. Default value: 1.
Public propertyCode exampleImageSubFolder Gets or sets a folder name which will be created by the component to store images. Default value: "images".
Public propertyCode exampleIncludeImageInHtml Allows to specify how to store images: Inside HTML document as base64 images or as linked separate image files. Default value: false.
Public propertyCode exampleInlineCSS Gets or sets a value whether to store CSS as inline for the each element using the "style" attribute or embed the whole style sheet inside HTML. Default value: true.
Public propertyKeepCharScaleAndSpacing Gets or sets a value to preserve the original char scaling and spacing or reset it to all symbols to 100%. Default value: true.
Public propertyMeasurementUnits Gets and sets the measurement units which will be used in the whole HTML document. Supported values: pt, px, pc, mm and cm. Default: pt.
Public propertyCode exampleProduceOnlyHtmlBody Gets or sets a value to produce a complete HTML document or only between between <body>...</body> tags. Default value: false.
Public propertyCode exampleRenderMode Gets or sets the rendering mode for the output HTML: Fixed or Flowing. Default value: Fixed.
Public propertyShowInvisibleText Gets or sets a value to show invisible text or not. Default value: false.
Public propertySingleFontColor Sets or gets a single font color in hex format '#XXXXXX' for a whole text in the produced HTML document. Default value: Empty.
Public propertySingleFontFamily Set a single font family for a whole text in the HTML document. Default value: Empty. We recommend use it only in the Flowing mode, in the Fixed mode it may shift/spoil to the document layout.
Public propertySingleFontSize Set a single font size in points (pt) for a whole text in the produced HTML document. Default value: null. We recommend use it only in the Flowing mode, in the Fixed mode it may shift/spoil to the document layout.
Public propertyCode exampleTitle Sets the title for the HTML document. Default value: "Untitled document".
Public propertyUseNumericCharacterReference In case of 'true': Write the all characters in "NCR" notation: &#xxx;. In case of 'false': Write the all characters as Unicode (recommended). Default value: false.
Top
Example
How to set a location of images during PDF to HTML in C#
using System;
using System.IO;
using SautinSoft;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            // Before starting, we recommend to get a free 100-day key:
            // https://sautinsoft.com/start-for-free/

            // Apply the key here:
            // SautinSoft.PdfFocus.SetLicense("...");

            // Here you will find how to keep images in the resulting HTML document.
            string pdfFile = Path.GetFullPath(@"..\..\..\simple text.pdf");
            string htmlFile = "Result.html";

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


            // Way 1 (default): Images will be stored inside HTML document as base64, jpeg images.
            /*
            f.HtmlOptions.IncludeImageInHtml = true;
            // Auto - the same image format as in the source PDF;
            // 'Jpeg' to make the document size less; 
            // 'PNG' to keep the highest quality, but the highest size too.
            f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Jpeg;
            */

            // Way 2: Images will be stored as JPG files in a special folder "{pdf name}_images".
            // Images will have names "picture100.jpg", "picture101.jpg" .. "pictureN.jpg".
            // Let's set the quality for jpeg to 95 percents.
            f.HtmlOptions.ImageFolder = Path.GetDirectoryName(htmlFile);
            // Auto - the same image format as in the source PDF;
            // 'Jpeg' to make the document size less; 
            // 'PNG' to keep the highest quality, but the highest size too.
            f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Jpeg;

            f.EmbeddedJpegQuality = 95;
            f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile));
            f.HtmlOptions.ImageFileName = "picture";
            f.HtmlOptions.ImageNumStart = 100;
            f.HtmlOptions.IncludeImageInHtml = false;

            // Way 3: Images will be stored as PNG files in the same directory with the HTML file.
            // All images on each page will be combined in a single image.
            /*
            f.HtmlOptions.ImageFolder = Path.GetDirectoryName(htmlFile);
            // 'Jpeg' to make the document size less; Or 'PNG' to keep the highest quality.
            f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Png;
            f.HtmlOptions.ImageSubFolder = "";
            f.HtmlOptions.IncludeImageInHtml = false;
            */

            f.OpenPdf(pdfFile);
            if (f.PageCount > 0)
            {
                int res = f.ToHtml(htmlFile);
                // Open the result for demonstration purposes.
                if (res == 0)
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFile) { UseShellExecute = true });
            }
        }
    }
}
How to set a location of images during PDF to HTML in VB.Net
Imports System
Imports System.IO
Imports SautinSoft

Namespace Sample
    Friend Class Sample
        Shared Sub Main(ByVal args() As String)
            ' Before starting, we recommend to get a free 100-day key:
            ' https://sautinsoft.com/start-for-free/

            ' Apply the key here
            ' SautinSoft.PdfFocus.SetLicense("...");

            ' Here you will find how to keep images in the resulting HTML document.
            Dim pdfFile As String = Path.GetFullPath("..\..\..\simple text.pdf")
            Dim htmlFile As String = "Result.html"

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

            ' Way 1 (default): Images will be stored inside HTML document as base64, jpeg images.
            'f.HtmlOptions.IncludeImageInHtml = True
            ' Auto - the same image format as in the source PDF;
            ' 'Jpeg' to make the document size less; 
            ' 'PNG' to keep the highest quality, but the highest size too.
            'f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Auto


            ' Way 2: Images will be stored as JPG files in a special folder "{pdf name}_images".
            ' Images will have names "picture100.jpg", "picture101.jpg" .. "pictureN.jpg".
            ' Let's set the quality for jpeg to 95 percents.
            f.HtmlOptions.ImageFolder = Path.GetDirectoryName(htmlFile)
            ' 'Jpeg' to make the document size less; Or 'PNG' to keep the highest quality.
            f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Jpeg
            f.EmbeddedJpegQuality = 95
            f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile))
            f.HtmlOptions.ImageFileName = "picture"
            f.HtmlOptions.ImageNumStart = 100
            f.HtmlOptions.IncludeImageInHtml = False

            ' Way 3: Images will be stored as PNG files in the same directory with the HTML file.
            ' All images on each page will be combined in a single image.            '            
            'f.HtmlOptions.ImageFolder = Path.GetDirectoryName(htmlFile)
            ' 'Jpeg' to make the document size less; Or 'PNG' to keep the highest quality.
            'f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Png
            'f.HtmlOptions.ImageSubFolder = ""
            'f.HtmlOptions.IncludeImageInHtml = False

            f.OpenPdf(pdfFile)
            If f.PageCount > 0 Then
                Dim res As Integer = f.ToHtml(htmlFile)
                ' Open the result for demonstration purposes.
                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