Document Writers

Use the LEADTOOLS DocumentWriters to create popular multipage and searchable document formats from SVG, EMF, and RasterImage objects.

Programming with the LEADTOOLS Document Writers

Output Formats

The LEADTOOLS DocumentWriters support the creation of the following document formats:

Input Pages

Create a document by adding one or more Leadtools.Document.Writer.DocumentWriterPage derived pages. Input data can include SVG, EMF, RasterImage, or an empty page.

SVG Input

The DocumentWriters support adding pages from standard SVG objects using the Leadtools.Document.Writer.DocumentWriterSvgPage class. Use one of the following methods to obtain an SVG document:

All of these methods return an ISvgDocument object that can be used to create documents as described later in this document.

The storage of size information in SVG documents is optional. If a document has a size, it is stored in the width and height attributes of the root svg element and can be in any coordinate system. An SVG renderer will typically use this value to determine the final bounding rectangle of the document. SVG documents contain a hierarchy of elements. The final transformation (such as position and size) and style (such as color and fill) may depend on the transformation and style of the parent(s) inside the hierarchy. Calculations have to be done to keep track of this information when converting the SVG file. This procedure is defined by LEADTOOLS as flattening the document. For more information, refer to SVG Size, Bounds, and Flat.

EMF Input

An EMF is a collection of structures that stores a picture in a device-independent format. Device independence is the one feature that sets metafiles apart from raster images. Unlike a raster image, a metafile guarantees device independence. EMF files can contain various objects such as Text, Lines, and raster images. EMF also contains Dots/Inch (DPI) information that is used to calculate the real size of the picture stored inside.

The DocumentWriters support adding pages from Windows Enhanced Metafile (EMF) objects by using the Leadtools.Document.Writer.DocumentWriterEmfPage class. These can be obtained from various sources, for example:

The Dots/Inch (DPI) of the page is the same as the DPI stored in the DocumentWriterEmfPage.EmfHandle property. For example, to create a page with 300 DPI, add a document page with an EMF having a DPI of 300 (both horizontally and vertically). This is just an example: the LEADTOOLS Document Writer supports different values for DPI. If you are using the PDF with image/text feature, set the DPI of the Leadtools.RasterImage object to the same DPI as the EMF handle using the RasterImage.XResolution and RasterImage.YResolution properties.

RasterImage Input

The DocumentWriters support adding pages from LEADTOOLS RasterImage objects using the Leadtools.Document.Writer.DocumentWriterRasterPage class. These can be obtained from various sources, for example:

Empty Pages

The DocumentWriters also support adding empty pages using the Leadtools.Document.Writer.DocumentWriterEmptyPage class.

Creating a Document

Perform the following steps to create a new document using the Leadtools.Document.Writer.DocumentWriter class:

Note: You can use a Leadtools.Document.Writer.DocumentWriter object to save one document at a time. After you call the DocumentWriter.BeginDocument method, end the document by adding the pages and then calling DocumentWriter.EndDocument before calling the DocumentWriter.BeginDocument method again to create a new document. DocumentWriter.BeginDocument will throw an exception if it is called while a document is already being created. You can create more than one instance of the Leadtools.Document.Writer.DocumentWriter class (each with its own options), if multiple documents need to be created at the same time. The object and all its operations are safe for multi-threading.

Format Options

Many of the document formats supported by the Leadtools.Document.Writer.DocumentWriter class contain extra options that are controlled through the use of the DocumentWriter.GetOptions and DocumentWriter.SetOptions methods. These options can be saved to an external XML file using the DocumentWriter.SaveOptions method. Then the options can be reloaded using the DocumentWriter.LoadOptions method.

Progress

The progress of the document creation operation can be monitored through the DocumentWriter.Progress event. For example, it can be to used provide visual feedback using a progress bar or to provide a means for the user to abort the operation using a cancel button.

LEADTOOLS Temporary Document

A LEADTOOLS Temporary Document (DocumentFormat.Ltd) can be used to create a persistent, temporary document file on disk to maintain pages between sessions. This can be helpful when you have large number of pages to add to a PDF document or when all of the pages cannot be obtained at the same time. (For example, in a server scenario a client may send one page at a time to the server.) After all of the pages are added to the temporary file on disk, you can call the DocumentWriter.Convert method to convert this file to the final document. You can also use the DocumentWriter.AppendLtd method to append pages from one LTD file to another.

See Also

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

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