LEADTOOLS Forms (Leadtools.Forms.DocumentWriters assembly)

DocDocumentOptions Class

Show in webframe
Example 







Members 
Provides extra options to use when saving a document using the Microsoft Word 2003 document format (DOC) format.
Object Model
Syntax
public class DocDocumentOptions : DocumentOptions 
'Declaration
 
Public Class DocDocumentOptions 
   Inherits DocumentOptions
'Usage
 
Dim instance As DocDocumentOptions
public sealed class DocDocumentOptions : DocumentOptions 

            

            
function Leadtools.Forms.DocumentWriters.DocDocumentOptions()
public ref class DocDocumentOptions : public DocumentOptions 
Remarks

The options set in the DocDocumentOptions class will be used when the user saves a document using the DocumentFormat.Doc format.

To change the options used with the DOC format, perform the following steps:

  1. Use the DocumentWriter.GetOptions method of the DocumentWriter object being used. Passing DocumentFormat.Doc to the format parameter. Note that the resulting object from the base DocumentOptions class needs to be cast to DocDocumentOptions.
  2. Use the various DocDocumentOptions properties to change the options.
  3. Use DocumentWriter.SetOptions to set the new options in the engine.
  4. Now you can call the DocumentWriter.BeginDocument method (with DocumentFormat.Doc for the format parameter) to create a new document and add the pages.

The DocDocumentOptions class contains the following properties:

Property Description
DocDocumentOptions.Framed Turn off or on the option to put the text blocks inside a frame (text box object) in the result DOC file.
Example
Copy Code  
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 DocDocumentOptionsExample()
   ' Create a new instance of the LEADTOOLS Document Writer
   Dim docWriter As New DocumentWriter()

   Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Test.doc")
   Dim emfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf")

   ' Change the DOC options to add frames to the file
   Dim docOptions As DocDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Doc), DocDocumentOptions)
   docOptions.Framed = True

   ' Use default resolution
   docWriter.SetOptions(DocumentFormat.Doc, docOptions)

   ' Create a new DOC document
   Console.WriteLine("Creating new DOC document: {0}", outputFileName)
   docWriter.BeginDocument(outputFileName, DocumentFormat.Doc)

   ' 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 DOC 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 DocDocumentOptionsExample()
{
   // Create a new instance of the LEADTOOLS Document Writer
   DocumentWriter docWriter = new DocumentWriter();

   string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.doc");
   string emfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf");

   // Change the DOC options to add frames to the file
   DocDocumentOptions docOptions = docWriter.GetOptions(DocumentFormat.Doc) as DocDocumentOptions;
   docOptions.Framed = true;

   docWriter.SetOptions(DocumentFormat.Doc, docOptions);

   // Create a new DOC document
   Console.WriteLine("Creating new DOC document: {0}", outputFileName);
   docWriter.BeginDocument(outputFileName, DocumentFormat.Doc);

   // 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 DOC file on disk
   docWriter.EndDocument();
}
Requirements

Target Platforms

See Also

Reference

DocDocumentOptions Members
Leadtools.Forms.DocumentWriters Namespace
DocumentWriter Class
Programming with LEADTOOLS Document Writers
Files to be Included with Your Application
Unlocking Special LEAD Features

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Forms.DocumentWriters requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features