Search KB Filter article types
PDF Printing Example for VisualWebGUI
Categories: Non Native VWG
Tags: Developers, Gateway, C#
Revision: 1
Posted: 03/Jan/2010
Updated: 03/Jan/2010
Status: Publish
Types: Code

The ability to create PDF reports on the fly and display them to the user in a separate Acrobat Reader window can be useful when developing new VWG applications. The attached code presents a very simple example of how to accomplish this.

This code snippet demonstrates using the iTextSharp open-source libraries to create a PDF report and then uses a standard gateway to display the report in a separate window on the user's browser. This snippet uses two classes, 'Form1.cs' which contains only a button which when clicked creates the report, and 'frmViewer.cs' which is the gateway to display the report.

Form1.cs needs a reference to 'itextsharp.dll' which can be downloaded from http://sourceforge.net/projects/itextsharp/ (be sure to add it as a reference to your project).

frmViewer.cs calls 'urlmon.dll' which provides the MIME type of the file to display. This dll is usually distributed with Internet Explorer so quite possibly it already exists somewhere on your machine. You should be able to find it on the MSDN site. Using urlmon makes frmViewer workable with different file types, so it is not limited to only PDF reports. Copy urlmon.dll to your bin directory.

This code example creates a simple PDF report with two tables and some HTML text and then calls the gateway to display the report on the user's browser.

 

Note: Codes are submitted as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Terms of Agreement:
By using this code, you agree to the following terms...

1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3. You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


About the author

Related Articles

Non Native VWG  
Title Update Author
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, ActiveX, Flash, v6.3, v6.4 and Later
30/Oct/2010    2010/10/30
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, ActiveX, Flash, v6.3, v6.4 and Later
13/Nov/2010    2010/11/13
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, ActiveX, Flash, v6.3, v6.4 and Later
30/Oct/2010    2010/10/30
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, DHTML, v6.3, v6.4 and Later
30/Oct/2010    2010/10/30
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, ActiveX, Flash, v6.3, v6.4 and Later
30/Oct/2010    2010/10/30
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS