Provides extra options to use when saving a document using the HyperText Markup Language (HTML) format.
Syntax
Visual Basic (Declaration) | |
---|
Public Class HtmlDocumentOptions
Inherits DocumentOptions |
Example
This example will create a new HyperText Markup Language document (HTML) file using the various supported options.
Visual Basic | Copy Code |
---|
<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()
RasterSupport.Unlock(RasterSupportType.DocumentWriters, "Replace with your own key here")
Dim docWriter As New DocumentWriter()
Dim outputFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Test.html"
Dim emfFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.emf"
Dim htmlOptions As HtmlDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Html), HtmlDocumentOptions)
htmlOptions.DocumentType = HtmlDocumentType.IENetscape
htmlOptions.FontEmbedMode = DocumentFontEmbedMode.None
htmlOptions.UseBackgroundColor = True
htmlOptions.BackgroundColor = Color.LightBlue
docWriter.SetOptions(DocumentFormat.Html, htmlOptions)
Console.WriteLine("Creating new HTML document: {0}", outputFileName)
docWriter.BeginDocument(outputFileName, DocumentFormat.Html)
Dim emfHandle As IntPtr = GetEnhMetaFile(emfFileName)
Dim page As DocumentPage = DocumentPage.Empty
page.EmfHandle = emfHandle
page.Image = Nothing
Console.WriteLine("Adding EMF page from: {0}", emfFileName)
docWriter.AddPage(page)
DeleteEnhMetaFile(emfHandle)
docWriter.EndDocument()
End Sub
|
C# | Copy Code |
---|
// 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() { // Unlock the support needed for LEADTOOLS Document Writers (with PDF output) RasterSupport.Unlock(RasterSupportType.DocumentWriters, "Replace with your own key here"); // Create a new instance of the LEADTOOLS Document Writer DocumentWriter docWriter = new DocumentWriter(); string outputFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Test.html"; string emfFileName = LeadtoolsExamples.Common.ImagesPath.Path + "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 = Color.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(); } |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also