Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 17817, TPrinterObj component for printing reports

by Andre Wolff Email: Anonymous


Component TPrinterObj prints TPicture, TStrings, TDBGrid, TListView controls with user defined header and footers. PageOrientation, margins, #copies, pagerange, fonts, boxes around text, can be set.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 5.0  to 7.0 2198 downloads
Copyright: Commercial use requires permission


Size: 54,910 bytes
Updated on Mon, 06 Jun 2005 02:43:51 GMT
Originally uploaded on Sat, 20 Apr 2002 00:18:07 GMT
SHA1 Hash: 36E50BBE9BA1348237F770C079A4A0CF3DB10568
MD5 Hash: 5B57CED76C849DDBCCC5BC0FA9EF59F9

    Explore the files in this upload

Description
Introduction to the PrinterObj component

Component PrinterObj can be used to print reports on a printer.
The default printer is used, unless method PrinterSetupSelected or PrintSelected is called to select another printer.

The user can define the contents and layout of headers and footers which will be printed on each new page. There are properties to define the page orientation, contents of the header and footers, the alignment and fonts to be used, the position of the page number, the color of text, background and lines etc.

There are methods to draw lines, boxes, pictures and strings at positions of a page indicated in mm or inches.

There are special methods to print the contents of TDBGrid and TListView controls. The width of a column is automatically adjusted so that al text is readable in the printed report. If a user closes a column, this columns will not printed (columns with a width<=4 on the screen are not printed).

A method to print the contents of TStrings allows you to print the contents of memo and list box controls etc.

TPrinterObj uses a coordinates system in mm or inches:
The upper left point of the highest header field is defined by point (0,0) and the lower right point of the lowest footer field is defines by coordinates (MaxReportWidth,MaxPrintHeight)
The upper left point of the report area below the headers is defined by the point (0,ReportTop) and the lower right point of the report area just above the footers is defines by the coordinates (MaxReportWidth, ReportBottom).

Component PrinterObj is after the installation available on component 'Wolff'. To use it, just drop it on a form and set properties with the object browser.

Example of the code of a report:

procedure TForm1.PrintReport;
begin
With PrinterObj1 do
if PrintSelected then
begin
ResetHeadersAndFooters;
LandscapeOrientation:= False;
HeaderOrFooterFields[1].Text:= 'Test PrintMemo';
HeaderOrFooterFields[2].Text:= vtxCopyright;
ReportFont.Assign(Memo1.Font);
DateTimeField:= 3;
DrawBoxAroundHeader:= True;
StartPrinting;
PrintNewLine;
PrintTStrings('Test PrintTStrings', Memo1.Lines, 5, MaxReportWidth-10, True, 0);
EndPrinting;
end;
end;

You will find the source code of this component in file PrinterObj.pas. The other source code files are part of test program TestPrinterObj used to test the component.

To install this component into the Component Palette 'Wolff', click menu item 'Component / Install Component...' and browse via the button right of field 'Unit file name' to file PrinterObj.Pas which should be saved in a directory indicated in the 'Search Path' field. Click 'OK' to rebuild the indicated package.

2003-06-07: PrintTStrings corrected
2003-06-19: The DataSource property of DBGrid1 on form TDBGridForm was empty, while it should contain TestPrObjCtrlForm.DataSource1
2003-06-19: PrintDBGrid changed according to the proposal of Peter Pas, DBGrids with predefined column titles and fieldindexes are now printed as you see it on the form.
2004-09-15: Readme file is now a html document, which you can view at site http://www.andrewolff.nl/Download_UK/index.htm
2005-05-24: Bug fix in PrintStringAtPos
2005-06-06: Module FileObj.pas was missing

For more information, see www.andrewolff.nl

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03