Click here to Skip to main content
Click here to Skip to main content

DaReport PrintDocument - a printing utility for .NET

, 20 Apr 2006
Rate this:
Please Sign up or sign in to vote.
A printing utility for .NET.



This component helps you generate simple but useful reports for printing in .NET. The idea is to generate XML-based templates, and then to call them from your program, and eventually to fill them with the data required. This is appropriate for generating small and simple printing documents.


The basic class of this project is DaPrintDocument. It inherits from the standard .NET class PrintDocument. Therefore, you can use it pretty much the same way as the PrintDocument class.

This class simply paints attached drawing objects within its PrintPage() method. For simplicity, there are only four types of drawing objects supported: TextField (simple formatted text), PictureBox (images), ChartBox (simple charts), and StyledTable (table with static or dynamically loaded data).

Template file overview

DaPrintDocument makes use of template files written in XML syntax. Those provide all static information relevant for printing a page.

You can write template files in any text editor, or alternatively, use the DaReport Designer (beta) provided in the distribution (it's a separate application: DaReportDesigner.exe).

The brief overview of the XML structure:


   <parameter name="parameter1_name" />
   <parameter name="parameter2_name" />


<!-- Static objects are evaluated once per report -->

      <!-- The list of static objects goes here. 
         Check in reportStatic.xml (in download package). -->

<!-- Dynamic objects are evaluated once per page of report 
      (like data table segment or page number) -->

      <!-- The list of dynamic objects goes here. 
        Check in reportDynamic.xml (in download package). -->



Once again, the preferred way for XML template file generation is by using the DaReport Designer (beta) provided in the distribution.

Using the code

First, add a reference to the daReport.dll file (provided in the distribution) to your project. If you feel like it, you can also put this component in your controls toolbar.

Second, add an instance of DaPrintDocument to your module (form); if you have previously attached it in your controls toolbar, simply drag it to your form:

private daReport.DaPrintDocument daPrintDocument = 
                         new daReport.DaPrintDocument();

At the point where you wish to print some report, set the template file and fill in the parameters (if any):

// set .xml file for printing

// fill in declared parameters (if any)
// (parameter names are case sensitive)
Hashtable parameters = new Hashtable();
parameters.Add("author","Predrag Dukanac");

Using tables

  • Static tables: static tables have data defined in an XML template file (DATA tag). The DataSource property for these tables is not set. No specific action is required in code for these tables to print correctly (everything is done in the .xml file).
  • Dynamic tables: dynamic tables present data calculated in your program (like database reports). The DataSource property is set, and must correspond to the DataTable.Name property in your code. Do it like this:
    // myTable is DataTable previously filled from database
    // (using DataAdapter.Fill method, for instance)
    DataTable printTable = myTable.Copy();
    printTable.Name = "printTable";
    // this is the DataSource attribute of my table in XML file
    // attach DataTable to printing document
    // now you're ready for print

Take a look at reportStatic.xml, reportDynamic.xml, reportCharts.xml, and the ReportTest project (all in the download package) for a deeper insight.

Latest update

The DaReport print engine has turned into a commercial product - Stampa Reports System®. A Stampa Reports demo is available for download here. Stampa designer features backward compatibility with daReport in design mode. The Stampa printing engine can be used free of charge.

The DaReport project at this address is still an open-source project by all means.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Predrag Dukanac
Web Developer
Serbia Serbia
Working at Mihajlo Pupin Institute, Belgrade, Serbia.

Comments and Discussions PinmemberPredrag Dukanac7-Dec-12 4:14 
GeneralRe: PinmemberTajniak511-Mar-13 5:57 
QuestionStampa Reports PinmemberAciobanita Costel18-Oct-12 2:30 
GeneralMy vote of 5 Pinmemberbiye5u1-Mar-12 21:08 
QuestionThanks a lot for this nice utility. PinmemberSunil Apte13-Oct-11 22:02 
Questionparameter in static table PinmemberMCY5-Dec-10 2:43 
GeneralMy vote of 5 PinmemberAnirudha_baba5-Jul-10 0:22 
QuestionMem usage problem!!!!!!!!!!! [Report design] Pinmemberutehn9-Jan-09 0:37 
QuestionUSE FREE PinmemberMember 323381631-Dec-08 6:00 
AnswerRe: USE FREE Pinmemberfraser12530-Jun-12 18:51 
Generalprinters on Pinmemberbalu1234530-Jul-08 8:41 
QuestionHow can I draw text or table only at the end of last page? PinmemberJM ® - DE CASTRO11-Jun-08 12:58 
GeneralVery nice PinmemberHugo Faselo13-Dec-07 12:16 
QuestionRe: Very nice Pinmemberdimazoid16-Oct-08 9:34 
QuestionMonday's date at the top of the report. Pinmemberdamonhogan16-Nov-07 6:48 
Questionmultple page in staticContent [modified] Pinmemberabhishek nath5-Feb-07 21:28 
AnswerRe: multple page in staticContent Pinmembernegleden25-May-09 15:46 
QuestionWhat royalties do i need to add into the help file? PinmemberNarutoFan#131-Oct-06 20:50 
AnswerRe: What royalties do i need to add into the help file? PinmemberPredrag Dukanac1-Nov-06 0:36 
GeneralRe: What royalties do i need to add into the help file? PinmemberNarutoFan#11-Nov-06 4:58 
GeneralHow to add image path? PinmemberNarutoFan#128-Feb-07 23:41 
QuestionReportDesigner Pinmemberbszom13-Oct-06 12:38 
QuestionFromPage/ToPage question Pinmemberbp00321-Jul-06 11:13 
GeneralFormatMask question Pinmembercalvin_cch3-Jun-06 16:40 
QuestionHow to print page numbers? Pinmembersteve_dee25-May-06 5:10 
AnswerRe: How to print page numbers? PinmemberPredrag Dukanac25-May-06 5:22 
GeneralRe: How to print page numbers? Pinmembersteve_dee25-May-06 5:37 
AnswerRe: How to print page numbers? PinmemberPredrag Dukanac25-May-06 21:23 
Generalnice job Pinmemberclody24-May-06 0:48 
QuestionMargin Pinmembercalvin_cch23-May-06 9:29 
AnswerRe: Margin PinmemberPredrag Dukanac24-May-06 3:44 
QuestionReport designer missing? Pinmemberjmw21-Apr-06 17:36 
GeneralDraw Text Only In the First Page Pinmembergeorani21-Apr-06 5:42 
GeneralRe: Draw Text Only In the First Page Pinmembercalvin_cch7-Jun-06 14:23 
GeneralRe: Draw Text Only In the First Page PinmemberPredrag Dukanac7-Jun-06 22:47 
GeneralSerdar Dirican's ReportCreator Pinmemberkennster21-Apr-06 5:35 
GeneralPozdrav! PinmemberVertyg020-Apr-06 15:32 
QuestionMargins?? Pinmembersteve_dee12-Apr-06 3:40 
QuestionLicense ? PinmemberM65C0216-Mar-06 23:49 
AnswerRe: License ? PinmemberPredrag Dukanac20-Mar-06 20:45 
QuestionTable in table PinmemberTim Hoffeller22-Feb-06 10:52 
AnswerRe: Table in table PinmemberPredrag Dukanac23-Feb-06 2:00 
GeneralProviding dynamic data PinmemberHerb21-Dec-05 7:12 
AnswerRe: Providing dynamic data PinmemberPredrag Dukanac21-Dec-05 21:02 
GeneralRe: Providing dynamic data PinmemberPredrag Dukanac21-Dec-05 21:12 
GeneralRe: Providing dynamic data PinmemberShurikEv2-Feb-06 2:16 
AnswerRe: Providing dynamic data PinmemberPredrag Dukanac2-Feb-06 21:24 
GeneralRe: Providing dynamic data PinmemberShurikEv2-Feb-06 22:24 
Questionstatic contents in picture but file name paramater PinmemberSuha17-Dec-05 13:42 
AnswerRe: static contents in picture but file name paramater PinmemberPredrag Dukanac20-Dec-05 20:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 20 Apr 2006
Article Copyright 2005 by Predrag Dukanac
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid