Provides extra options to use when saving a document using the LEADTOOLS Temporary Document (LTD) format.
[SerializableAttribute()][DataContractAttribute()]public class LtdDocumentOptions : DocumentOptions
<DataContractAttribute()><SerializableAttribute()>Public Class LtdDocumentOptionsInherits DocumentOptions
@interface LTLtdDocumentOptions : LTDocumentOptions <NSCopying, NSCoding> public class LtdDocumentOptions extends DocumentOptions [DataContractAttribute()][SerializableAttribute()]public ref class LtdDocumentOptions : public DocumentOptions
The options set in the LtdDocumentOptions class will be used when the user saves a document using the DocumentFormat.Ltd format.
The LEADTOOLS Temporary Document (LTD) format is a proprietary that support 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 DocumentFormat.Ltd 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, you can use the DocumentWriter.Convert method to convert this temporary file to the desired output format such as PDF, HTML or DOC.
To change the options used with the LTD format, perform the following steps:
Note that this format supports both DocumentWriter.AddPage and DocumentWriter.InsertPage.
Currently, the LtdDocumentOptions class contains no extra options.
This example will create a new LEADTOOLS Temporary Document (LTD) over multiple sessions then convert the result to a PDF file.
using Leadtools.Document.Writer;using Leadtools;using Leadtools.Codecs;public void LtdDocumentOptionsExample(){var inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.docx");var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf");var ltdFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.ltd");// Check if the LTD file exists, if so, delete it so we start a new sessionif (File.Exists(ltdFileName))File.Delete(ltdFileName);// Get the number of pagesint 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 LTDfor (var pageNumber = 1; pageNumber < pageCount; pageNumber++){AppendToLtd(inputFileName, pageNumber, ltdFileName);}// Create a new instance of the LEADTOOLS Document Writervar docWriter = new DocumentWriter();// Set the PDF options to be PDF/A with Image/Textvar 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 PDFConsole.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 needvar docWriter = new DocumentWriter();using (var codecs = new RasterCodecs()){codecs.Options.RasterizeDocument.Load.Resolution = 300;// Create a new (or append if the file exists) LTD documentdocWriter.BeginDocument(ltdFileName, DocumentFormat.Ltd);// Load the page as SVG document and as Raster imageConsole.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 featurevar page = new DocumentWriterSvgPage();page.SvgDocument = svgDocument;page.Image = image;Console.WriteLine("Adding page {0} ...", pageNumber);docWriter.AddPage(page);}}// Finally finish writing the PDF file on diskdocWriter.EndDocument();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports Leadtools.Document.WriterImports LeadtoolsImports Leadtools.CodecsPublic Sub LtdDocumentOptionsExample()Dim inputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.docx")Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf")Dim ltdFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Example.ltd")' Check if the LTD file exists, if so, delete it so we start a new sessionIf File.Exists(ltdFileName) Then File.Delete(ltdFileName)' Get the number of pagesDim pageCount As IntegerUsing codecs As New RasterCodecs()codecs.Options.RasterizeDocument.Load.Resolution = 300pageCount = codecs.GetTotalPages(inputFileName)End Using' Loop through the pages and add them to the LTDFor pageNumber As Integer = 1 To pageCountAppendToLtd(inputFileName, pageNumber, ltdFileName)Next' Create a new instance of the LEADTOOLS Document WriterDim docWriter As New DocumentWriter()' Set the PDF options to be PDF/A with Image/TextDim pdfOptions As PdfDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Pdf), PdfDocumentOptions)pdfOptions.DocumentType = PdfDocumentType.PdfApdfOptions.ImageOverText = TruedocWriter.SetOptions(DocumentFormat.Pdf, pdfOptions)' Now convert the LTD file we generated to PDFConsole.WriteLine("Converting LTD to PDF")docWriter.Convert(ltdFileName, outputFileName, DocumentFormat.Pdf)End SubPrivate Sub AppendToLtd(inputFileName As String, pageNumber As Integer, ltdFileName As String)' This assumes we are in a separate session than the main program, so create' a new instance of the RasterCodecs and DocumentWriter objects we needDim docWriter As New DocumentWriter()Using codecs As New RasterCodecs()codecs.Options.RasterizeDocument.Load.Resolution = 300' Create a new (or append if the file exists) LTD documentdocWriter.BeginDocument(ltdFileName, DocumentFormat.Ltd)' Load the page as SVG document and as Raster imageConsole.WriteLine("Loading page {0} ...", pageNumber)Using svgDocument As ISvgDocument = codecs.LoadSvg(inputFileName, pageNumber, Nothing)Using image As RasterImage = codecs.Load(inputFileName, pageNumber)' Add the page, notice we will be using image/text featureDim page As New DocumentWriterSvgPage()page.SvgDocument = svgDocumentpage.Image = imageConsole.WriteLine("Adding page {0} ...", pageNumber)docWriter.AddPage(page)End UsingEnd UsingEnd Using' Finally finish writing the PDF file on diskdocWriter.EndDocument()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Leadtools.Document.Writer Namespace
Programming with LEADTOOLS Document Writers
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
