Visual Basic (Declaration) | |
---|---|
Public Class DocumentWriter |
Visual Basic (Usage) | Copy Code |
---|---|
|
C# | |
---|---|
public class DocumentWriter |
C++/CLI | |
---|---|
public ref class DocumentWriter |
This example shows how to create document file using basic functionality of the DocumentWriter class.
Visual Basic | Copy Code |
---|---|
' Windows API functions needed to load/delete an EMF |
C# | Copy Code |
---|---|
// Windows API functions needed to load/delete an EMF |
The DocumentWriter and the LEADTOOLS Document Writers toolkit is used to create multi-page and searchable documents from one or more Windows Enhanced Meta File (EMF) objects.
Support for various popular formats is included, such as PDF, XPS, DOC, HTML, RTF or Text. For a list of all the document formats supported, refer to the DocumentFormat enumeration.
To create a document from EMF, perform the following steps
Create an instance of the DocumentWriter class. Optional: Set the document options required. For example, to save the final document as PDF/A instead of the default PDF, use DocumentWriter.GetOptions to get an instance of the current PDF options stored in a PdfDocumentOptions object. Change the PdfDocumentOptions.DocumentType property to PdfDocumentType.Pdf and finally set the options back with the DocumentWriter.SetOptions method. Optional: If it is necessary to monitor the process or provide the capablity to abort the operation, subscribe to the DocumentWriter.Progress event. Creates a new document by calling the DocumentWriter.BeginDocument method with the requested output file name and format. Add the EMF objects as pages to the document. First create an instance of the DocumentPage structure and set the DocumentPage.EmfHandle property to the EMF for the first page. When creating a PDF file with the "image over text" overlay option, set the DocumentPage.Image property to the overlay image for this page. Finally, call DocumentWriter.AddPage to add the page to the current document. Repeat the step above for each page in the source document. Finally, call DocumentWriter.EndDocument to finalize the document and create it on disk. Note: Use a DocumentWriter object to save one document at a time. Once DocumentWriter.BeginDocument is called the document needs to end (by adding the pages and then call DocumentWriter.EndDocument before calling DocumentWriter.BeginDocument to create a new document. Calling DocumentWriter.BeginDocument while a document is already being created will result in an exception being thrown.
The Windows Enhanced Meta File (EMF) objects can be obtained from various sources as shown in the following list:
The LEADTOOLS Annotations toolkit has support for creating an EMF file representation of the annotation objects in a container. Therefore, you can use the Annotations toolkit to create a document. Then populate it with various annotations objects and then save the result as a PDF file using the DocumentWriter class. The Document Writer demo shipping with the LEADTOOLS Toolkit shows an example of this scenario. For more information, refer to Programming With LEADTOOLS Annotations. The LEADTOOLS Virtual Printer Driver toolkit allows you to capture output from any Windows application as an EMF handle. You can then use the DocumentWriter class to convert this output to a PDF, HTML or a DOC document. For more information, refer to LEADTOOLS Virtual Printer Driver. The Windows Enhanced Meta File (EMF) is a standard format in Microsoft Windows. Many other applications and frameworks provide support for outputting as EMF. You can convert the output from any such application or framework to any of the document formats supported by the DocumentWriter.
Many of the document formats supported by DocumentWriter contain extra options and functionality that can be controlled through the use of the DocumentWriter.GetOptions and DocumentWriter.GetOptions 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. Your application can provide a visual feedback using a progress bar and a cancel button to the user to allow both monitoring and abortion of the current 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 DOC).
The Dots/Inch (DPI) of the page is the same as the DPI stored in the DocumentPage.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 or vertically although the LEADTOOLS Document Writer supports different values for the DPI). When using the PDF with image/text feature, set the DPI of the RasterImage object to the same DPI as the EMF handle using the RasterImage.XResolution and RasterImage.YResolution properties.
System.Object
Leadtools.Forms.DocumentWriters.DocumentWriter
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
Reference
DocumentWriter MembersLeadtools.Forms.DocumentWriters Namespace
DocumentPage Structure
DocumentFormat Enumeration
Programming with LEADTOOLS Document Writers
Files to be Included with Your Application
Unlocking Special LEAD Features
Introduction
Getting Started (Guide to Example Programs)
LEADTOOLS Document Writers .NET Assemblies