Leadtools.Forms.DocumentWriters Namespace : DocxDocumentOptions Class |
public class DocxDocumentOptions : DocumentOptions
'Declaration Public Class DocxDocumentOptions Inherits DocumentOptions
'Usage Dim instance As DocxDocumentOptions
public sealed class DocxDocumentOptions : DocumentOptions
function Leadtools.Forms.DocumentWriters.DocxDocumentOptions()
public ref class DocxDocumentOptions : public DocumentOptions
The options set in the DocxDocumentOptions class will be used when the user saves a document using the DocumentFormat.Docx format.
To change the options used with the DOCX(2007/2010) format, perform the following steps:
The DocxDocumentOptions class contains the following properties:
Property | Description |
---|---|
DocxDocumentOptions.Framed | Turn off or on the option to put the text blocks inside a frame (text box object) in the resulting DOCX(2007/2010) file. |
This format requires .NET framework 3.0 and Microsoft Open XML Format SDK 1.0. The Microsoft Open XML Format SDK requires Windows Server 2003 family or later, Windows Vista or later, or Windows XP Service Pack 2. For more information, refer to Files to be Included with Your Application.
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 DocxDocumentOptionsExample() ' Create a new instance of the LEADTOOLS Document Writer Dim docWriter As New DocumentWriter() Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Test.docx") Dim emfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf") ' Change the DOCX(2007/2010) options to add frames to the file Dim docxOptions As DocxDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Docx), DocxDocumentOptions) docxOptions.Framed = True docWriter.SetOptions(DocumentFormat.Docx, docxOptions) ' Create a new DOCX(2007/2010) document Console.WriteLine("Creating new DOCX(2007/2010) document: {0}", outputFileName) docWriter.BeginDocument(outputFileName, DocumentFormat.Docx) ' 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 DOCX(2007/2010) 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 DocxDocumentOptionsExample() { // Create a new instance of the LEADTOOLS Document Writer DocumentWriter docWriter = new DocumentWriter(); string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.docx"); string emfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf"); // Change the DOCX(2007/2010) options to add frames to the file DocxDocumentOptions docxOptions = docWriter.GetOptions(DocumentFormat.Docx) as DocxDocumentOptions; docxOptions.Framed = true; docWriter.SetOptions(DocumentFormat.Docx, docxOptions); // Create a new DOCX(2007/2010) document Console.WriteLine("Creating new DOCX(2007/2010) document: {0}", outputFileName); docWriter.BeginDocument(outputFileName, DocumentFormat.Docx); // 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 DOCX(2007/2010) file on disk docWriter.EndDocument(); }