Leadtools.Forms.DocumentWriters Namespace : HtmlDocumentOptions Class |
public class HtmlDocumentOptions : DocumentOptions
'Declaration Public Class HtmlDocumentOptions Inherits DocumentOptions
'Usage Dim instance As HtmlDocumentOptions
public sealed class HtmlDocumentOptions : DocumentOptions
function Leadtools.Forms.DocumentWriters.HtmlDocumentOptions()
public ref class HtmlDocumentOptions : public DocumentOptions
The options set in the HtmlDocumentOptions class will be used when the user saves a document using the DocumentFormat.Html format.
To change the options used with the DOC format, perform the following steps:
The HtmlDocumentOptions class contains the following properties:
Property | Description |
---|---|
HtmlDocumentOptions.DocumentType | The type of the HTML document (Internet Explorer or Netscape compatible). |
HtmlDocumentOptions.FontEmbedMode | Control how the fonts are embedded in the final document created by the LEADTOOLS Document Writer. |
HtmlDocumentOptions.UseBackgroundColor and HtmlDocumentOptions.BackgroundColor | Set a background color in the final HTML document. |
Imports Leadtools.Forms.DocumentWriters Imports Leadtools ' Windows API functions needed to load/delete an EMF <DllImport("gdi32.dll")> _ Private Shared Function GetEnhMetaFile(ByVal lpszMetaFile As String) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function DeleteEnhMetaFile(ByVal hemf As IntPtr) As Boolean End Function Private Sub HtmlDocumentOptionsExample() ' Create a new instance of the LEADTOOLS Document Writer Dim docWriter As New DocumentWriter() Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Test.html") Dim emfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf") ' Change the HTML options to add a background color Dim htmlOptions As HtmlDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Html), HtmlDocumentOptions) htmlOptions.DocumentType = HtmlDocumentType.IENetscape htmlOptions.FontEmbedMode = DocumentFontEmbedMode.None htmlOptions.UseBackgroundColor = True htmlOptions.BackgroundColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue) docWriter.SetOptions(DocumentFormat.Html, htmlOptions) ' Create a new HTML document Console.WriteLine("Creating new HTML document: {0}", outputFileName) docWriter.BeginDocument(outputFileName, DocumentFormat.Html) ' Use the Windows API to load the EMF Dim emfHandle As IntPtr = GetEnhMetaFile(emfFileName) ' Add the page Dim page As DocumentPage = DocumentPage.Empty page.EmfHandle = emfHandle page.Image = Nothing Console.WriteLine("Adding EMF page from: {0}", emfFileName) docWriter.AddPage(page) ' Use the Windows API to delete the EMF DeleteEnhMetaFile(emfHandle) ' Finally finish writing the HTML file on disk docWriter.EndDocument() End Sub
using Leadtools.Forms.DocumentWriters; using Leadtools; using Leadtools.Drawing; // Windows API functions needed to load/delete an EMF [DllImport("gdi32.dll")] private static extern IntPtr GetEnhMetaFile(string lpszMetaFile); [DllImport("gdi32.dll")] private static extern bool DeleteEnhMetaFile(IntPtr hemf); private void HtmlDocumentOptionsExample() { // Create a new instance of the LEADTOOLS Document Writer DocumentWriter docWriter = new DocumentWriter(); string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.html"); string emfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf"); // Change the HTML options to add a background color HtmlDocumentOptions htmlOptions = docWriter.GetOptions(DocumentFormat.Html) as HtmlDocumentOptions; htmlOptions.DocumentType = HtmlDocumentType.IENetscape; htmlOptions.FontEmbedMode = DocumentFontEmbedMode.None; htmlOptions.UseBackgroundColor = true; htmlOptions.BackgroundColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue); docWriter.SetOptions(DocumentFormat.Html, htmlOptions); // Create a new HTML document Console.WriteLine("Creating new HTML document: {0}", outputFileName); docWriter.BeginDocument(outputFileName, DocumentFormat.Html); // Use the Windows API to load the EMF IntPtr emfHandle = GetEnhMetaFile(emfFileName); // Add the page DocumentPage page = DocumentPage.Empty; page.EmfHandle = emfHandle; page.Image = null; Console.WriteLine("Adding EMF page from: {0}", emfFileName); docWriter.AddPage(page); // Use the Windows API to delete the EMF DeleteEnhMetaFile(emfHandle); // Finally finish writing the HTML file on disk docWriter.EndDocument(); }