Click here to Skip to main content
13,288,104 members (53,133 online)
Click here to Skip to main content
Add your own
alternative version


101 bookmarked
Posted 2 Feb 2007

BizDraw framework for .NET

, 30 May 2007
Rate this:
Please Sign up or sign in to vote.
A small framework to design and print documents containing shapes, text, images, bar codes...


I have been using Framework .NET since 2003. I have now mastered ADO.NET and data manipulation, and can't imagine working with another framework. However, I was constrained to create a tool for our company users to enable the creation of some special documents that need free-hand painting and special printing features. In the beginning, I was wondering if .NET Framework had the required features enabled to create such applications. That's because I had already experienced similar tries with VB 6 and the result was "NULL."

After a few hours of work and searching over the web, I was impressed with the power of the .NET Framework, especially when having seen the Paint.NET project. So, I decided to create a small -- but very useful, I hope -- framework to satisfy our users and myself. Now I am sure that the .NET Framework is not only about the System.Data namespace, but that there are a lot of other interesting namespaces to discover too. Here is a preview of what we can do with the BizDraw application. I am using it now to create employee badges (used for registration) and also tickets with bar codes for manufacturing products.

Sample image

The framework

I begin with a brief description of the framework namespaces.


The Core namespace contains the Document object that is the core of the framework. You can access the properties and methods of the document programatically to do anything you do with the designer: Adding/moving /changing objects, printing, saving, loading, etc.


Here are all the objects you can insert in a document: Text, Line, Rectangle, Ellipse, BarCode, Free hand drawing. Any new object must be added in this namespace, such as an image object. All of these objects inherit from the DrawObject abstract class. The namespace also contains editors for the drawing object. Generally, each object has its own editor. We found some exceptions though, like for rectangle and ellipse objects, that have the same editor because they have the same properties. I could create a unique editor based on a PropertyGrid, but I preferred this way to have a better user interface. Here is a preview of the Text Object Editor:

Sample image


Tools are needed in the BizDraw designer. Each Drawing Object has its tool to define actions, cursor, etc. Of course, the Pointer tool is a special tool that is used with all objects for selection, resizing and moving operations.


This contains the DocumentManager class that enables Saving/Loading operations. Here, Binary serialization is used. The namespace can be extended to handle export/import operations, i.e. BMP, PDF, Word, etc.


Printing is the most interesting feature in this framework. It's not just a single document print; you can print many documents on the same piece of paper depending on your document size, the paper size and the margins. For example, you can print 44 documents of size 2.5 cm x 5 cm on a single piece of A4 paper. You can also customize which cells you want to print using the mouse in the preview screen. Here is the print preview screen:

Sample image


In the introduction, I said that I am a fan of the System.Data .NET namespace, so it's not surprising that I implemented my own BizDraw.Data namespace. This namespace is used to connect a document to a database. Thus, instead of having static text fields, you can bind text objects with a field from a table or query. The connection string editor and the query editor are far from being Visual Studio 2005 wizards, but they just work fine.


For backward compatibility reasons, I added this namespace to enable use of this framework with COM. So, VB6 developers (as Excel, MFC, etc.) can enjoy the framework without any coding effort. They just have to compile the project within Visual Studio and insert the DocumentSpace control directly from their Visual Studio 6 IDE, just as an OCX. I finished testing it and my VB6 application looks like a .NET application, especially with the .NET 2.0 ToolBar.


Here is a special namesapce for barcodes. I implemented EAN13 bar code -- thanks to Grand Zebu for the code he provided -- but other bar code formats can be easily implemented via the IBarCode interface. Please don't worry about updating the BarCodeEditor form; it's already done using reflection.

Using the framework

This framework provides the necessary controls; all you have to do is drag and drop the DocumentSpace control into your form from the toolbox after adding a reference to BizDraw.dll. You can also use the DocumentArea control instead. In this case, you have to define your menus and catch the necessary events to update the user interface. Another way to use the framework is programatically. You can create a new document, add some objects, save the document and print it to the printer. Here a small example:

//Creating the Document
BizDraw.Core.Document myDoc = new Document();
myDoc.Name = "Simple test";
myDoc.Height = 25;
myDoc.Width = 50;
//Adding a text object
BizDraw.Objects.DrawText myText = new BizDraw.Objects.DrawText();
myText.Location = new PointF(0, 0);
myText.Font = new Font("Verdana", 14);
myText.Text = "Sample text object";
//Saving the document
BizDraw.IO.DocumentManager.Save(myDoc, @"c:\Docs\SampleDoc.bzw");
//Printing 44 copies of the document
BizDraw.Printing.DocumentPrintEngine printEngine = new DocumentPrintEngine();
printEngine.Count = 44;
printEngine.Document = myDoc;
printEngine.Format = PrintFormat.GetFormats()[0]; 
    // gets the first format in the formats directory
//Freeing resources
myDoc = null; // We can also implemebnt IDisposable to the Document class
printEngine = null;

To do

  • Implement Undo/Redo Actions
  • Implement more Barcodes
  • Implement more data providers, as only SQL Server is provided
  • In the framework, I am using measurement units of mm for the user interface, pixels for the screen display and inches for the printers; some modifications must be done to use one measurement unit in all parts


This has been a good opportunity for me to change from classic ADO.NET developments. I hope this framework will be useful for at least one person.


  • 5/30/2007
    • Article edited and posted to the main article base
  • 3/1/2007
    • Bug Fix: Only selected cells in preview mode are printed
    • Image support added to the application
  • 2/2/2007
    • First version published on Code Project


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

Hayder Marzouk
Web Developer
France France
MCSD Asp.Net certified developer

You may also be interested in...

Comments and Discussions

QuestionWhich Design Pattern you are using for Pin
eg_Anubhava15-Nov-11 19:57
membereg_Anubhava15-Nov-11 19:57 
QuestionHow to Work with Undo Redo Option Pin
eg_Anubhava23-Jul-10 3:11
membereg_Anubhava23-Jul-10 3:11 
QuestionHow To Rotate Text in 180 Angle Pin
eg_Anubhava2-Jun-10 0:51
membereg_Anubhava2-Jun-10 0:51 
GeneralText Not Showing Clear Pin
eg_Anubhava18-May-10 22:36
membereg_Anubhava18-May-10 22:36 
GeneralNot Focus Polygon Pin
eg_Anubhava6-Dec-09 19:14
membereg_Anubhava6-Dec-09 19:14 
GeneralGetting Error :Space Required for this process Pin
eg_Anubhava27-Nov-09 22:20
membereg_Anubhava27-Nov-09 22:20 
GeneralText Font Error Pin
eg_Anubhava25-Nov-09 2:10
membereg_Anubhava25-Nov-09 2:10 
GeneralPage Is Out Of Display Pin
eg_Anubhava12-Nov-09 0:02
membereg_Anubhava12-Nov-09 0:02 
GeneralGenerating Error while Draging Control Pin
eg_Anubhava24-Aug-09 20:33
membereg_Anubhava24-Aug-09 20:33 
GeneralRe: Generating Error while Draging Control Pin
eg_Anubhava24-Aug-09 21:07
membereg_Anubhava24-Aug-09 21:07 
GeneralDisplaying "template" and printing "overlay" question. Pin
Dustin Fast16-Apr-09 14:50
memberDustin Fast16-Apr-09 14:50 
GeneralRe: Displaying "template" and printing "overlay" question. Pin
nussknacker25-Jun-09 12:37
membernussknacker25-Jun-09 12:37 
GeneralIncredibly Helpful Pin
Dustin Fast16-Apr-09 14:20
memberDustin Fast16-Apr-09 14:20 
GeneralSome maybe helpful code 'corrections' [modified] Pin
nussknacker21-Jan-09 3:38
membernussknacker21-Jan-09 3:38 
GeneralAdd Layers Pin
AntonioMelli4-Jun-08 8:58
memberAntonioMelli4-Jun-08 8:58 
GeneralRe: Add Layers Pin
nussknacker2-Jul-09 1:57
membernussknacker2-Jul-09 1:57 
Questionhelp for undo and redo functions [modified] Pin
san2112018-Apr-08 2:44
membersan2112018-Apr-08 2:44 
QuestionWould like Rulers that scroll like Word or Visio Pin
nsaban3-Apr-08 0:37
membernsaban3-Apr-08 0:37 
GeneralZooming question Pin
22sas4-Feb-08 20:33
member22sas4-Feb-08 20:33 
GeneralCode 39 Pin
i22camua11-Jul-07 1:23
memberi22camua11-Jul-07 1:23 
GeneralHelp Pin
dragonlil18-Jun-07 20:30
memberdragonlil18-Jun-07 20:30 
GeneralRe: Help Pin
Hayder Marzouk19-Jun-07 23:55
memberHayder Marzouk19-Jun-07 23:55 
GeneralRe: Help Pin
Hayder Marzouk21-Jun-07 0:39
memberHayder Marzouk21-Jun-07 0:39 
GeneralRe: Help Pin
dragonlil21-Jun-07 2:15
memberdragonlil21-Jun-07 2:15 
QuestionHow to bind textfields to barcodes? Pin
phiberx12-Jun-07 16:56
memberphiberx12-Jun-07 16:56 
GeneralGreat Pin
merlin98131-May-07 4:18
membermerlin98131-May-07 4:18 
GeneralNeed your Help Pin
NETA200329-Apr-07 11:43
memberNETA200329-Apr-07 11:43 
GeneralRe: Need your Help Pin
Hayder Marzouk29-Apr-07 23:52
memberHayder Marzouk29-Apr-07 23:52 
GeneralRe: Need your Help Pin
NETA200330-Apr-07 12:43
memberNETA200330-Apr-07 12:43 
Questionthank you, it is a good works Pin
k_hammami20059-Mar-07 1:19
memberk_hammami20059-Mar-07 1:19 
AnswerRe: thank you, it is a good works Pin
Hayder Marzouk9-Mar-07 2:25
memberHayder Marzouk9-Mar-07 2:25 
GeneralRe: thank you, it is a good works Pin
k_hammami200512-Mar-07 4:31
memberk_hammami200512-Mar-07 4:31 
QuestionProblems with creating bar code Pin
str_test2-Mar-07 5:46
memberstr_test2-Mar-07 5:46 
AnswerRe: Problems with creating bar code Pin
Hayder Marzouk5-Mar-07 0:27
memberHayder Marzouk5-Mar-07 0:27 
GeneralRe: Problems with creating bar code Pin
str_test7-Mar-07 9:51
memberstr_test7-Mar-07 9:51 
GeneralRe: Problems with creating bar code Pin
Hayder Marzouk7-Mar-07 20:44
memberHayder Marzouk7-Mar-07 20:44 
GeneralNice ! Pin
Vertyg01-Mar-07 22:16
memberVertyg01-Mar-07 22:16 
GeneralRe: Nice ! Pin
Hayder Marzouk1-Mar-07 22:24
memberHayder Marzouk1-Mar-07 22:24 
GeneralRe: Nice ! Pin
Vertyg01-Mar-07 22:37
memberVertyg01-Mar-07 22:37 
GeneralRe: Nice ! Pin
Hayder Marzouk1-Mar-07 22:48
memberHayder Marzouk1-Mar-07 22:48 
GeneralRe: Nice ! Pin
Vertyg01-Mar-07 22:59
memberVertyg01-Mar-07 22:59 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 30 May 2007
Article Copyright 2007 by Hayder Marzouk
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid