Programming with the LEADTOOLS Document Writers

Input Pages

The LEADTOOLS Document Writers allows you to create popular multi-page and searchable document formats from SVG, EMF or raster image objects.

Support for the creating documents with the following formats is included:

Input Pages

A document is created by adding one or more Leadtools.Forms.DocumentWriters.DocumentPage derived pages. These include input data as SVG, EMF, Raster Image or an empty page.

SVG Input

Document writer supports adding pages from standard SVG objects using the Leadtools.Forms.DocumentWriters.DocumentSvgPage class. These can be obtained from various sources, for example:

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

SVG documents may or may not have a size. 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.

EMF Input

Document writer supports adding pages from Windows Enhanced Metafile (EMF) objects using the Leadtools.Forms.DocumentWriters.DocumentEmfPage class. These can be obtained from various sources, for example:

An EMF is a collection of structures that store 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. The EMF 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 Dots/Inch (DPI) of the page is the same as the DPI stored in the DocumentEmfPage.EmfHandle property. Therefore, to create a page with 300 DPI, you must add a document page with an EMF that has a DPI of 300 (both horizontally and vertically although the LEADTOOLS Document Writer supports different values for the DPI). If you are using the PDF with image/text feature, you must set the DPI of the Leadtools.RasterImage object to the same DPI as the EMF handle using the RasterImage.XResolution and RasterImage.YResolution properties.

Image Input

Document writer supports adding pages from LEADTOOLS RasterImage objects using the Leadtools.Forms.DocumentWriters.DocumentRasterPage class. These can be obtained from various sources, for example:

Empty Pages

Document Writer also supports adding empty pages using the Leadtools.Forms.DocumentWriters.DocumentEmptyPage class.

Creating a Document

Perform the following to create a new document using the Leadtools.Forms.DocumentWriters.DocumentWriter class:

Note: You can use a Leadtools.Forms.DocumentWriters.DocumentWriter object to save one document at a time, once you call DocumentWriter.BeginDocument, you must end the document first (by adding the pages and then call DocumentWriter.EndDocument before calling DocumentWriter.BeginDocument again to create a new document. Calling DocumentWriter.BeginDocument while a document is already being created will result in an exception being thrown. You can always create more than one instance of Leadtools.Forms.DocumentWriters.DocumentWriter if multiple documents are to be created at the same time each with their own options. The object and all its operations is multi-threaded safe.

Format Options

Many of the document formats supported by Leadtools.Forms.DocumentWriters.DocumentWriter contain extra options and functionality that can be controlled through the use of the DocumentWriter.GetOptions and DocumentWriter.SetOptions methods. These options can be set and then saved to an external XML file using the DocumentWriter.SaveOptions method. Later, you can re-load these options using the DocumentWriter.LoadOptions method.

Support is provided to monitor the document creation operation through the DocumentWriter.Progress event. Use this in your application to provide visual feedback using a progress bar and a Cancel button so the user can monitor and if necessary, abort the operation.

The LEADTOOLS Temporary Document format (DocumentFormat.Ltd) allows you to create a temporary document on disk that you can add pages to in between sessions. This can be helpful when you have large amount of pages to add to a PDF document for example or when not all the pages can be obtained at the same time (for example, in a server scenario when the client sends one page to the server at a time). After all pages are added to the temporary file on disk, you can use the DocumentWriter.Convert method to convert this file to the final document (for example PDF or DOCX). You can also use the DocumentWriter.AppendLtd method to append pages from one LTD file to another.

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Imaging, Medical, and Document
Click or drag to resize