Leadtools.Forms.DocumentWriters Namespace : XpsDocumentOptions Class |
public class XpsDocumentOptions : DocumentOptions
'Declaration Public Class XpsDocumentOptions Inherits DocumentOptions
'Usage Dim instance As XpsDocumentOptions
public sealed class XpsDocumentOptions : DocumentOptions
function Leadtools.Forms.DocumentWriters.XpsDocumentOptions()
public ref class XpsDocumentOptions : public DocumentOptions
The options set in the XpsDocumentOptions class will be used when the user saves a document using the DocumentFormat.Xps format.
To change the options used with the XPS format, perform the following steps:
Currently, the XpsDocumentOptions class contains no extra options.
This format requires .NET framework 3.0.
Imports Leadtools.Forms.DocumentWriters Imports Leadtools Imports Leadtools.Codecs ' 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 XpsDocumentOptionsExample() ' 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 Dim docWriter As New DocumentWriter() Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Test.xps") Dim emfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf") Dim xpsOptions As XpsDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Xps), XpsDocumentOptions) docWriter.SetOptions(DocumentFormat.Xps, xpsOptions) ' Create a new XPS document Console.WriteLine("Creating new XPS document: {0}", outputFileName) docWriter.BeginDocument(outputFileName, DocumentFormat.Xps) ' 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 XPS file on disk docWriter.EndDocument() End Sub
using Leadtools.Forms.DocumentWriters; using Leadtools; // 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 XpsDocumentOptionsExample() { // Create a new instance of the LEADTOOLS Document Writer DocumentWriter docWriter = new DocumentWriter(); string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.xps"); string emfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf"); XpsDocumentOptions xpsOptions = docWriter.GetOptions(DocumentFormat.Xps) as XpsDocumentOptions; // Use default resolution docWriter.SetOptions(DocumentFormat.Xps, xpsOptions); // Create a new XPS document Console.WriteLine("Creating new XPS document: {0}", outputFileName); docWriter.BeginDocument(outputFileName, DocumentFormat.Xps); // 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 XPS file on disk docWriter.EndDocument(); }