Click here to Skip to main content
15,867,950 members
Articles / Web Development / HTML

Printing Framework

Rate me:
Please Sign up or sign in to vote.
3.77/5 (10 votes)
22 Nov 20032 min read 65K   3.3K   28   3
Simple framework for text and graphic Printing/Previewing

The documentation for this article, which appears to be quite extensive, is in French, as are the source code comments. If you need translation, you can http://world.altavista.com/. Also, please be aware of the explicitly stated LGPL license for this code. -- Editor

A basic window:

a basic window

The component provides a hardcopy print & print preview. (In this case, no custom header/footer)

hardcopy

The picture shows the preview for a 'text' preview. The framework calculates the number of pages. The user simply has to put data in a CPrinterText instance. In this case, we use a derived class to customize the header and the footer...

preview textcopy 1/2

preview textcopy 2/2

Introduction

The source contains PDF and HTML documentation with UML schema, refactoring & a using section. A small demonstration project is also present in this zip.

The code simplifies the print and preview of a window. The main idea is to provide a canvas for obtain a 'textual view' of the data.

Users have just to describe the contains of a windows in a CDocText. The framework calculates the number of characters per page and the number of pages.

The formatting is simple but sufficient for current needs:

  • Customize header & footer
  • Bold or normal fonts
  • EmptyLine, Title, Data=(Label, Value), List

FreeText and FreeTable

Using the Code

The printer DLL contains all the code. So the $Devp\bin must be in the $PATH to execute the program 'test.exe' (or you must copy the DLL in your source project).

All the source is in the namespace printer, so use instruction like using namespace printer; to access classes.

The directory 'Test' contains a small demo. In this project, we show how we can use a factory to simplify the creation of textual view. In this particular case, the project must activate the RTTI and accept some limitations in the choice of resource's name.

A more traditional way is always possible: just add data to your CTextPrinter instance with instruction like:

textPrinter->AddTitle("Title"); 
textPrinter->AddData("Label", "Value"); 
...

Licence

  • LGPL - See /Doc/Licence/Lgpl.txt

Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralVector !!! Pin
Member 75620128-May-04 2:45
Member 75620128-May-04 2:45 

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.