Leadtools.Forms.DocumentWriters Namespace : EmfDocumentOptions Class |
public class EmfDocumentOptions : DocumentOptions
'Declaration Public Class EmfDocumentOptions Inherits DocumentOptions
'Usage Dim instance As EmfDocumentOptions
public sealed class EmfDocumentOptions : DocumentOptions
function Leadtools.Forms.DocumentWriters.EmfDocumentOptions()
public ref class EmfDocumentOptions : public DocumentOptions
The Windows Enhanced Meta File (EMF) format does not support multi-page documents. Therefore, only the last page added with the DocumentWriter.AddPage will be used in the final document.
The options set in the EmfDocumentOptions class will be used when the user saves a document using the DocumentFormat.Emf format.
To change the options used with the EMF format, perform the following steps:
Currently, the EmfDocumentOptions class contains no extra options.
' 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 EmfDocumentOptionsExample() ' Create a new instance of the LEADTOOLS Document Writer Dim docWriter As New DocumentWriter() Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Test.emf") Dim emfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf") ' Create a new EMF document Console.WriteLine("Creating new EMF document: {0}", outputFileName) docWriter.BeginDocument(outputFileName, DocumentFormat.Emf) ' 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 PDF file on disk docWriter.EndDocument() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
// 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 EmfDocumentOptionsExample() { // Create a new instance of the LEADTOOLS Document Writer DocumentWriter docWriter = new DocumentWriter(); string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.emf"); string emfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf"); // Create a new EMF document Console.WriteLine("Creating new EMF document: {0}", outputFileName); docWriter.BeginDocument(outputFileName, DocumentFormat.Emf); // 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 PDF file on disk docWriter.EndDocument(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2