TEasyPrint Component 

General

Fonts

TEasyPrint comes with 5 Fonts, these Fonst are dedicated to particular printing outputs. There is a font for the first header line (Header1Font), for the second header line  (Header2Font), for headlines (HeadLineFont), für bold font (BoldFont) and for the normal font (NormalFont).
These fonts may be changed at  runtime at any time.

Internal Resolution

TEasyPrint works internal with a resolution of 1000 x 1000 Pixel, indepedentent from the physical resolution of the printer. Therefore the center of the page is described by the values  500, 500.
 

Header Lines

There are two header lines avaiable (Header1 and Header2), these header lines will be printed on every new page. Every header line has its own font (Header1Font and Header2Font).  If more header lines are needed, this can be achieved by the Event "AfterPrintHeader". The header lines are normally normalerweise left aligned, right alignment can be switched on by the characters "||" (2 x ASCII 179)  in the Textstring. All characters in front of "||" are left - aligned and all following characters are  right - aligned printed.

Makros

There are so-called "makros" in any textstring allowed. "Makros" are defined by the term $(Makroname). Actually there is only one Makro $(Page) implemented, it replaces itself  in the textstring with the actual page count.
 

Methods:

void __fastcall AbortPrinting ();

This method aborts the printing process.

bool __fastcall PrintBitmap (AnsiString BitmapFilename, AnsiString Headline,float x,float y);
bool __fastcall PrintBitmap (AnsiString BitmapFilename, AnsiString HeadLine);
bool __fastcall PrintBitmap (AnsiString BitmapFilename);

This method prints the Bitmap from the file "BitmapFilename", provided the the headline "HeadLine" with the scaling factors "x" und "y" at the postion, where the internal y - Cursor actually is. The scaling factor "1" means original size. Scaling factor 0,5 means half - size and "2" double size.
If you do not use scaling factors the scaling factor "1" is used.

bool __fastcall PrintText (int x,AnsiString Text);
bool __fastcall PrintText (AnsiString text);   // not indented

This Method prints the contents of the variable "text", with the actual font left-indented by "x" logical at the actual position of the y - cursor.

bool __fastcall PrintMemo (TMemo *m,AnsiString headline);
bool __fastcall PrintMemo (TMemo *m);   // Without Headline

This method prints the contents of the handed over TMemo - Object provided with the headline "headline" at the position where the y - cursor actually is.
 

bool __fastcall PrintTable (AnsiString s [],int x_count,int y_count,AnsiString headline);
bool __fastcall PrintTable (AnsiString s [],int x_count,int y_count);

This method prints the contents of the Arrays s in table order, x_count contains the count of columns. "x_count" must contain either the values  2 or 4 (two or four columns), y_count contains the count of rows in s. The columns are internally so computed, that the largest item is fitting in.
"headline" contains a optional headline. The first and the third column are printed with the font "BoldFont". Do you not wish that, put "BoldFont" with the function "Assign" to  "NormalFont".

 bool __fastcall PrintList (TListBox *t);
 bool __fastcall PrintList (TListBox *t,AnsiString headline);

This mehod prints the contents of a handed over TListBox - object inclusive an optional headline.

void __fastcall SetPrinterIndex (short index);

This method sets the variable "PrinterIndex" (see Delphi or C++ Builder help, it is useful if the printer dialog should not appear (the printing starts immediatly)).

int __fastcall GetPrinterIndex ();

This method returns the actual value of the variable "PrinterIndex".

void __fastcall PrintEnd ()

This method is finishing the print and must be called whenever "PrintInit" was called before.

bool __fastcall Print (TListView *tl);
bool __fastcall Print (TTreeView *tv);
bool __fastcall Print (TListView *tl,int from,int to);
bool __fastcall Print (TTreeView *tv,int from,int to);

This method prints the contents of a handed over TListView- or TTreeView - Object, the optional parameters "from" and "to" indicate the index of the items you want to print. For example the values 5,100 are meaning, that from the 5th up to the 100th item all items are printed.
The ListView-Object must have the ViewStyle "vsReport".
See "Options" too.

int __fastcall GetPageHeight ();

This method returns the height of the page in physical pixel (not logical pixel)

int __fastcall GetPageWidth ();

This method returns the width of the page in physical pixel (not logical).

void __fastcall NewPage ();

This methods triggers a new page.

bool __fastcall PrintInit ();

This method must be called if you start a printing operation and you want to print more than one Object, in either case this function is called internally. If you call this method, you have to call at the end of the printing process always "PrintEnd". If the user aborts the printer dialog, "PrintInit" returns "FALSE" otherwise "TRUE". If you want to prevent the printer dialog, call "SetPrinterIndex" before "PrintInit".

Sample:

void SampleApplication.PrintSample_1 ()
{
    EasyPrint->Print (TreeViewObject);      // Only one Object is printed, no call to PrintInit ()
}

void SampleApplication.PrintSample_2 ()
{
    if (!EasyPrint->Init ()) return;     // More than one printing operation, a call to "PrintInit" is nesccessary
    EasyPrint->Print (TreeViewObject);
    EasyPrint->NewLine ();
    EasyPrint->Print (ListViewObject);
    EasyPrint->PrintEnd ();                          // Don't forget a call to "PrintEnd ()"

}

void __fastcall SetFont (TFont *f);

This method changes the current font by assigning the adjusted values of the handed over TFont - object to the current font object.
 

void __fastcall GetFont (TFont *f);

This method returns the current font in "TFont". TFont must be a valid object.

 int __fastcall GetColumn ();

If a table is just printed (see "PrintTable"), this method returns the current column.
If there are just header lines printed, this methods returns for left - aligning header lines "0" and "1" for right - aligning header lines.
If there is just a  TListView - Object to be printed with the method "Print", the current column is returned, if a TTreeView - Objekt is printed, this method returns the level of the current item to be printed. In all other cases the return value is undefined.

 int __fastcall GetRow ();

If there is a table just to be printed (see "PrintTable"), this method returns the current row.
If there are header lines just to be printed, this method returns for the first header line -3 and -2 for the second header line.
If there is a  TListView- or a TTreeView- object to be printed with the method "Print", the current row. In all other cases the return value is undefined.
 

void __fastcall NewLine (double t);
void __fastcall NewLine ()

This method triggers a new line. If you provide a factor in the variable "t",  "LineSpacing" will be muliplicated with this factor, for getting a line spacing different from the current default value.
 
 
 
 
 

Properties

BoldFont:  Properties for bold font.

ConfFileName: Name of the file, to load the current printing properties at runtime from.
If the user should have the oppertunity to change the printing shape itself, you can write to this file the current printing properties of the user. The file must have the format of the structure "PrintConf"  (you can find it in PrintConf.h). The properties, which are provided in this file, overwrites the properties commited at design time. The program "printconf.exe" comes with sourcecode as C++ Builder 4  Procekt, or "printconf5.exe" as C++ Builder 5 Project. It shows how to manage the properties of the printing parameters for the  EasyPrint - Package. You can use this program directly or you can use it modified.

FrameLines: Properties for the frame lines

Bottom: Spacing between the bottom frame line and the bottom edge of the page  in logical pixels.
Left: Spacing between the left frame line and the left edge of the page in logical pixels.
Pen:  line art und solidation of the frame lines
PrintBottomFrameLine: Should the bottom frame line be printed?
PrintLeftFrameLine: Should the left frame line be printed?
PrintRightFrameLine: Should the right frame line be printed?
PrintTopFrameLine: Should the top frame line be printed?


Header1: Text of the first header line

Header1Font: Font of the first header line

Header2: Text of the second header line

Header2Font: Font of the second header line

HeadLineFont: Font for headlines

LineSpacing: Line spacing as a value  multiplicated with the height of a fictive row printed with the current font.

Margins: Space from the edges of the page in logical pixels.
The value in "Margins" built a rectangle in which all printing will happen.

Bottom: bottom logical edge
Left: left logical edge
Right: right logical edge
Top: top logical edge


Options:

TreeView: Options for printing the contents of a  TreeView - Control:
Indent: Indent  in logical pixel for every level of the tree
Numbering: Scientific numbering of the particular items of the TreeView
ParentHeadLine: If a item has "children" (a parent node is), he his printed with the font "HeadLineFont"
Pen: kind of line  for PrintLines
PrintImages: the icons of the TreeView are printed
PrintLines: The particular items of the TreeView - Control are printed with connected lines  (how they appear on the screen).
PrintStateImages: The "State" - icons of the TreeView - Control are printed (if there are any).


PrintLogo: You can print on every page a bitmap (your logo)

Bitmap:  TBitmap - object to be printed
Bottom, Left, Right, Top: Rectangle in logical pixels, in which the bitmap will be printed.

Events

AfterPrintHeader: Method is called, after the header lines are printed.
BeforeNewPage:  Method is called, before a new page is triggered.
BeforePrintHeader: Method is called, before the header lines will be printed.
OnPrintEnd: Method is called, before finishing the print.
OnPrintItem: Method is called, before a string objekt will be printed.
If you overwrite the contents of the handed over AnsiString - object, the new contants is printed instead of the old. In addition you have here the oppertunity to change the font etc..