←Select platform

Format Property

Summary
Gets the document format type associated with this options class.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public override DocumentFormat Format { get; } 
@property (nonatomic, assign, readonly) LTDocumentFormat format 
@Override public DocumentFormat getFormat() 
public: 
property DocumentFormat Format { 
   DocumentFormat get() override; 
} 
Format # get  (LtdDocumentOptions) 

Property Value

This property will always return DocumentFormat.Ltd.

Remarks

This property is required internally by LEADTOOLS.

Example
C#
Java
using Leadtools.Document.Writer; 
using Leadtools; 
using Leadtools.Codecs; 
 
 
public void LtdDocumentOptionsExample() 
{ 
   var inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "test_2.docx"); 
   var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "test_Example_password.pdf"); 
   var ltdFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example2.ltd"); 
 
   // Check if the LTD file exists, if so, delete it so we start a new session 
   if (File.Exists(ltdFileName)) 
      File.Delete(ltdFileName); 
 
   // Get the number of pages 
   int pageCount; 
   using (var codecs = new RasterCodecs()) 
   { 
      codecs.Options.RasterizeDocument.Load.Resolution = 300; 
      pageCount = codecs.GetTotalPages(inputFileName); 
   } 
 
   // Loop through the pages and add them to the LTD 
   for (var pageNumber = 1; pageNumber <= pageCount; pageNumber++) 
   { 
      AppendToLtd(inputFileName, pageNumber, ltdFileName); 
   } 
 
   // Create a new instance of the LEADTOOLS Document Writer 
   var docWriter = new DocumentWriter(); 
 
   // Set the PDF options to be PDF/A with Image/Text 
   var pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; 
   pdfOptions.DocumentType = PdfDocumentType.PdfA; 
   pdfOptions.ImageOverText = true; 
   docWriter.SetOptions(DocumentFormat.Pdf, pdfOptions); 
 
   // Now convert the LTD file we generated to PDF 
   Debug.WriteLine("Converting LTD to PDF"); 
   docWriter.Convert(ltdFileName, outputFileName, DocumentFormat.Pdf); 
} 
 
private void AppendToLtd(string inputFileName, int pageNumber, string ltdFileName) 
{ 
   // This assumes we are in a separate session than the main program, so create 
   // a new instance of the RasterCodecs and DocumentWriter objects we need 
   var docWriter = new DocumentWriter(); 
   using (var codecs = new RasterCodecs()) 
   { 
      codecs.Options.RasterizeDocument.Load.Resolution = 300; 
 
      // Create a new (or append if the file exists) LTD document 
      docWriter.BeginDocument(ltdFileName, DocumentFormat.Ltd); 
 
      // Load the page as SVG document and as Raster image 
      Debug.WriteLine("Loading page {0} ...", pageNumber); 
      using (var svgDocument = codecs.LoadSvg(inputFileName, pageNumber, null)) 
      using (var image = codecs.Load(inputFileName, pageNumber)) 
      { 
         // Add the page, notice we will be using image/text feature 
         var page = new DocumentWriterSvgPage(); 
         page.SvgDocument = svgDocument; 
         page.Image = image; 
 
         Debug.WriteLine("Adding page {0} ...", pageNumber); 
         docWriter.AddPage(page); 
      } 
   } 
 
   // Finally finish writing the PDF file on disk 
   docWriter.EndDocument(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
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 static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.document.writer.*; 
 
 
public void ltdDocumentOptionsExample() { 
   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, "test_Example_password.pdf"); 
   String ltdFileName = combine(LEAD_VARS_IMAGES_DIR, "Example2.ltd"); 
   File ltdFile = new File(ltdFileName); 
 
   // Check if the LTD file exists, if so, delete it so we start a new session 
   if (ltdFile.exists()) { 
      ltdFile.delete(); 
   } 
 
   // Get the number of pages 
   int pageCount; 
   RasterCodecs codecs = new RasterCodecs(); 
 
   codecs.getOptions().getRasterizeDocument().getLoad().setResolution(300); 
   pageCount = codecs.getTotalPages(inputFileName); 
   codecs.dispose(); 
 
   // Loop through the pages and add them to the LTD 
   for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++) { 
      appendToLtd(inputFileName, pageNumber, ltdFileName); 
   } 
 
   // Create a new instance of the LEADTOOLS Document Writer 
   DocumentWriter docWriter = new DocumentWriter(); 
 
   // Set the PDF options to be PDF/A with Image/Text 
   PdfDocumentOptions pdfOptions = (PdfDocumentOptions) docWriter.getOptions(DocumentFormat.PDF);// as statement 
                                                                                                 // example at top or 
                                                                                                 // other program!! 
   pdfOptions.setDocumentType(PdfDocumentType.PDFA); 
   pdfOptions.setImageOverText(true); 
   docWriter.setOptions(DocumentFormat.PDF, pdfOptions); 
 
   // Now convert the LTD file we generated to PDF 
   System.out.println("Converting LTD to PDF"); 
   docWriter.convert(ltdFileName, outputFileName, DocumentFormat.PDF); 
 
   assertTrue("Page added", pageCount > 0); 
   System.out.println("Command run, pages added"); 
 
} 
 
private void appendToLtd(String inputFileName, int pageNumber, String ltdFileName) { 
 
   // This assumes we are in a separate session than the main program, so create 
   // a new instance of the RasterCodecs and DocumentWriter objects we need 
   DocumentWriter docWriter = new DocumentWriter(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.getOptions().getRasterizeDocument().getLoad().setResolution(300); 
 
   // Create a new (or append if the file exists) LTD document 
   docWriter.beginDocument(ltdFileName, DocumentFormat.LTD); 
 
   // Load the page as SVG document and as Raster image 
   System.out.printf("Loading page %s ...", pageNumber); 
   ISvgDocument svgDocument = codecs.loadSvg(inputFileName, pageNumber, null); 
   RasterImage image = codecs.load(inputFileName, pageNumber); 
 
   // Add the page, notice we will be using image/text feature 
   DocumentWriterSvgPage page = new DocumentWriterSvgPage(); 
   page.setSvgDocument(svgDocument); 
   page.setImage(image); 
 
   assertTrue("success", page.getSvgDocument() == svgDocument); 
   System.out.println("Command run, pages added"); 
 
   System.out.printf("Adding page %s ...", pageNumber); 
   docWriter.addPage(page); 
   codecs.dispose(); 
 
   // Finally finish writing the PDF file on disk 
   docWriter.endDocument(); 
 
} 
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.