←Select platform

DocumentFormat Enumeration

Summary
Specifies the output document formats supported by the LEADTOOLS Document Writers.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
[DataContractAttribute()] 
public enum DocumentFormat 
typedef NS_ENUM(NSInteger, LTDocumentFormat) { 
 LTDocumentFormatUser = -1,  
 LTDocumentFormatLtd = 0,  
 LTDocumentFormatPdf = 1,  
 LTDocumentFormatDoc = 2,  
 LTDocumentFormatRtf = 3,  
 LTDocumentFormatHtml = 4,  
 LTDocumentFormatText = 5,  
 LTDocumentFormatEmf = 6,  
 LTDocumentFormatXps = 7,  
 LTDocumentFormatDocx = 8,  
 LTDocumentFormatXls = 9,  
 LTDocumentFormatPub = 10,  
 LTDocumentFormatMob = 11,  
 LTDocumentFormatSvg = 12,  
 LTDocumentFormatAltoXml = 13,  
}; 
public enum DocumentFormat 
[DataContractAttribute()] 
[SerializableAttribute()] 
public enum class DocumentFormat 
class DocumentFormat(Enum): 
   Ltd = 0 
   Pdf = 1 
   Doc = 2 
   Rtf = 3 
   Html = 4 
   Text = 5 
   Emf = 6 
   Xps = 7 
   Docx = 8 
   Xls = 9 
   Pub = 10 
   Mob = 11 
   Svg = 12 
   AltoXml = 13 
   Xlsx = 14 
   User = -1 
Members
Value Member Description
-1 User User-defined document format. The User document format is not used inside the LEADTOOLS Document Writers toolkit. An exception will be thrown if User is used as an output document format in the DocumentWriter.BeginDocument method. The User format can however be used as an output format when used in the LEADTOOLS OCR toolkit as a special case to instruct the OCR framework to save the document using the engine native format.
0 Ltd LEADTOOLS Temporary Document. This format creates a temporary file on disk that can later be converted to any of the other formats supported by the LEADTOOLS Document Writers.This format supports appending pages to an existing file, therefore, you can use the Ltd format if you have large amount of pages to convert over multiple sessions. When calling the DocumentWriter.BeginDocument method with the Ltd document format, the toolkit will check if the output file specified exists on disk. If it does, the new pages will be appended to the end of the file. When you are finished adding all the pages use the DocumentWriter.Convert method to convert this temporary file to the desired output format.
1 Pdf Adobe Portable Document Format (PDF).LEADTOOLS Document Writers support several flavors with multiple options of the PDF format, for more information refer to PdfDocumentOptions. Note: The PDF document support requires unlocking an extra key before it can be used. For more information, refer to RasterSupportType and Unlocking Special LEAD Features.
2 Doc Microsoft Word 2003 document format (DOC).LEADTOOLS Document Writers support extra options for the DOC format. For more information refer to DocDocumentOptions.
3 Rtf Rich Text Format (RTF).LEADTOOLS Document Writers support extra options for the RTF format. For more information refer to RtfDocumentOptions.
4 Html HyperText Markup Language (HTML).LEADTOOLS Document Writers support several flavors with multiple options of the HTML format. For more information refer to HtmlDocumentOptions.
5 Text Text format.LEADTOOLS Document Writers support extra options for the Text format. For more information refer to TextDocumentOptions.
6 Emf Windows Enhanced Meta File (EMF).EMF format does not support multipage documents. Therefore, only the last page added with DocumentWriter.AddPage or DocumentWriter.InsertPage will be used in the final document.
7 Xps Microsoft Open XML Paper Specification (XPS) (this format requires .NET Framework 3.0 or later).LEADTOOLS Document Writers support extra options for the XPS format. For more information refer to XpsDocumentOptions.
8 Docx Microsoft Word Document format (DOCX) (this format requires .NET Framework 3.0 or later and Microsoft Open XML Format SDK 2.*.).The DOCX format is part of Microsoft Open XML specification and first introduced with Microsoft Office 2007.LEADTOOLS Document Writers support extra options for the DOCX format. For more information refer to DocxDocumentOptions.
9 Xls Microsoft Excel 2003 format (XLS).LEADTOOLS Document Writers support extra options for the XLS format. For more information refer to XlsDocumentOptions.
10 Pub eBooks format (ePUB).LEADTOOLS Document Writers support extra options for the ePUB format. For more information refer to PubDocumentOptions.
11 Mob Mobipocket e-book format (MOB).LEADTOOLS Document Writers support extra options for the MOB format. For more information refer to MobDocumentOptions.
12 Svg Scalable Vector Graphics format (SVG).SVG format does not support multipage documents. Therefore, only the last page added with the AddPage will be used in the final document.For more information refer to SvgDocumentOptions.
13 AltoXml ALTO (Analyzed Layout and Text Object) is an XML Schema used by the library of congress to describe OCR text and layout format.LEADTOOLS Document Writers support extra options for the ALTO format. LEADTOOLS supports ALTO XML version 1 using UTF-8 encoding. For more information refer to AltoXmlDocumentOptions.
14 Xlsx Microsoft Open XML Spreadsheet (XLSX).
Remarks

The DocumentFormat enumeration specifies the output format for the final document created with the LEADTOOLS Document Writers. Pass the format that are desired to the DocumentWriter.BeginDocument method.

To get or set the extra options supported by a format, use the DocumentWriter.GetOptions and DocumentWriter.SetOptions methods.

Some of the document formats require a special key to unlock. When using these formats unlock the specified support using the RasterSupport class first.

The following table lists the document formats and the support type required to be unlocked before using them:

Document Format Support Type
Doc, Docx, Emf, Html, Ltd, Rtf, Text, Pup, Mob, AltoXml, Svg, User and Xls. RasterSupportType.DocumentWriters
Pdf and Xps RasterSupportType.DocumentWriters and RasterSupportType.DocumentWritersPdf

Note: Not all formats are supported in all platforms. Use DocumentWriter.GetSupportedFormats to find the current level of support.

Example
C#
Java
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:\LEADTOOLS23\Resources\Images"; 
} 
 
import static org.junit.Assert.assertTrue; 
 
import java.io.ByteArrayInputStream; 
import java.io.ByteArrayOutputStream; 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.document.writer.*; 
import leadtools.ocr.*; 
 
 
public void documentWriterExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String inputFileName = combine(LEAD_VARS_IMAGES_DIR, "LEADTOOLSEditor.docx"); 
   String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "Example.pdf"); 
 
   // Setup a new RasterCodecs object 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.getOptions().getRasterizeDocument().getLoad().setResolution(300); 
 
   // Get the number of pages in the input document 
   ILeadStream leadStream = LeadStreamFactory.create(inputFileName); 
   int pageCount = codecs.getTotalPages(leadStream); 
 
   // Create a new instance of the LEADTOOLS Document Writer 
   DocumentWriter docWriter = new DocumentWriter(); 
 
   // Change the PDF options 
   PdfDocumentOptions pdfOptions = (PdfDocumentOptions) docWriter.getOptions(DocumentFormat.PDF); 
   pdfOptions.setDocumentType(PdfDocumentType.PDFA); 
   docWriter.setOptions(DocumentFormat.PDF, pdfOptions); 
 
   // Create a new PDF document 
   System.out.printf("Creating new PDF document: %s", outputFileName); 
   docWriter.beginDocument(outputFileName, DocumentFormat.PDF); 
 
   // Loop through all the pages 
   for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++) { 
      // Get the page as SVG 
      System.out.printf("Loading page %s", pageNumber); 
      DocumentWriterSvgPage page = new DocumentWriterSvgPage(); 
      page.setSvgDocument(codecs.loadSvg(inputFileName, pageNumber, null)); 
 
      // Add the page 
      System.out.printf("Adding page %s", pageNumber); 
      docWriter.addPage(page); 
 
      page.getSvgDocument().dispose(); 
   } 
 
   // Finally finish writing the PDF file on disk 
   docWriter.endDocument(); 
   assertTrue((new File(outputFileName)).exists()); 
   codecs.dispose(); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 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.