←Select platform

SetOptions Method

Sets the extra options to use when saving a document using the specified format.
public void SetOptions( 
   DocumentFormat format, 
   DocumentOptions options 
- (void)setOptions:(nullable __kindof LTDocumentOptions *)options forFormat:(LTDocumentFormat)format; 
public void setOptions(DocumentFormat format, DocumentOptions options) 
void SetOptions(  
   DocumentFormat format, 
   DocumentOptions^ options 


The document format.

An instance of an object derived from DocumentOptions. The remarks section lists the various document formats and the derived object that can be used.


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

Format (the value of 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. Use the DocumentWriter.GetOptions method of the DocumentWriter object you are using passing DocumentFormat desired in to the  format parameter. Note that the resulting object from the base DocumentOptions class needs to be cast to appropriate derived class described in the table above.
  2. Use the various derived class 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 the desired DocumentFormat for the format parameter) to create a new document and add the pages.
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); 
   // Finally finish writing the PDF file on disk 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 

Target Platforms

Help Version 22.0.2023.2.4
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.