←Select platform

DocumentOptions Class

Summary
Abstract base class that provides functionality common to all the format option classes in the LEADTOOLS Document Writers.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
[DataContractAttribute()] 
public abstract class DocumentOptions 
@interface LTDocumentOptions : NSObject<NSCopying, NSCoding> // ABSTRACT 
public abstract class DocumentOptions 
[DataContractAttribute()] 
[SerializableAttribute()] 
public ref class DocumentOptions abstract  
class DocumentOptions: 
Remarks

You cannot use the DocumentOptions class directly. Instead, use one of the derived classes to get and set the options associated with that document format. The following table lists the document formats and the corresponding DocumentOptions derived class associated with each format:

Format Class
DocumentFormat.Ltd LtdDocumentOptions
DocumentFormat.Pdf PdfDocumentOptions
DocumentFormat.Doc DocDocumentOptions
DocumentFormat.Rtf RtfDocumentOptions
DocumentFormat.Html HtmlDocumentOptions
DocumentFormat.Text TextDocumentOptions
DocumentFormat.Emf EmfDocumentOptions
DocumentFormat.Xps XpsDocumentOptions
DocumentFormat.Docx DocxDocumentOptions
DocumentFormat.Xls XpsDocumentOptions
DocumentFormat.AltoXml AltoXmlDocumentOptions

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

  1. Call the DocumentWriter.GetOptions method for the DocumentWriter object being used, passing the DocumentFormat to be used in the format parameter. The resulting object from the base DocumentOptions class needs to be cast to the appropriate derived class described in the previous table.

  2. Use the various derived class properties to change the options.

  3. Call DocumentWriter.SetOptions to set the new options for the engine.

  4. Now call the DocumentWriter.BeginDocument method (using the DocumentFormat value for the format parameter) to create a new document and add the pages.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
using Leadtools.Ocr; 
 
 
public void DocumentWriterExample() 
{ 
   var inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "test.docx"); 
   var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf"); 
 
   // Setup a new RasterCodecs object 
   var codecs = new RasterCodecs(); 
   codecs.Options.RasterizeDocument.Load.Resolution = 300; 
 
   // Get the number of pages in the input document 
   var pageCount = codecs.GetTotalPages(inputFileName); 
 
   // Create a new instance of the LEADTOOLS Document Writer 
   var docWriter = new DocumentWriter(); 
 
   // Change the PDF options 
   var pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; 
   pdfOptions.DocumentType = PdfDocumentType.PdfA; 
   docWriter.SetOptions(DocumentFormat.Pdf, pdfOptions); 
 
   // Create a new PDF document 
   Debug.WriteLine("Creating new PDF document: {0}", outputFileName); 
   docWriter.BeginDocument(outputFileName, DocumentFormat.Pdf); 
 
   // Loop through all the pages 
   for (var pageNumber = 1; pageNumber <= pageCount; pageNumber++) 
   { 
      // Get the page as SVG 
      Debug.WriteLine("Loading page {0}", pageNumber); 
      var page = new DocumentWriterSvgPage(); 
      page.SvgDocument = codecs.LoadSvg(inputFileName, pageNumber, null); 
 
      // Add the page 
      Debug.WriteLine("Adding page {0}", pageNumber); 
      docWriter.AddPage(page); 
 
      page.SvgDocument.Dispose(); 
   } 
 
   // Finally finish writing the PDF file on disk 
   docWriter.EndDocument(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Writer Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.