Board index » delphi » TPrinter prints blank pages

TPrinter prints blank pages

        I'm trying to use the Delphi TPrinter object or this component
written by some guy that will, for now, print ANYTHING.  I'm trying to
print to a network printer so maybe that is causing some problems but
I can tell it is finding them because when I display Delphi's print
dialog box it lists all of the available network printers.  If I
send something to the printer, all that comes out is a blank page.

Marshall

 

Re:TPrinter prints blank pages


In article: <40b95f$...@hecate.umd.edu>  marsh...@news.umd.edu (Marshall Cory Hendricks) writes:
Quote

>    I'm trying to use the Delphi TPrinter object or this component
> written by some guy that will, for now, print ANYTHING.  I'm trying to
> print to a network printer so maybe that is causing some problems but
> I can tell it is finding them because when I display Delphi's print
> dialog box it lists all of the available network printers.  If I
> send something to the printer, all that comes out is a blank page.

> Marshall

Here is a code example of printing...

procedure TMainForm.SpeedButton1Click(Sender: TObject);
var
  Y: integer;
  iLoop1: integer;

begin
  with Printer do
  begin
     Title := 'Printing a report';
     BeginDoc;
     Canvas.Font.Name := 'Arial';
     Canvas.Font.Size := 10;
     Canvas.Font.Style := [fsItalic];
     Canvas.TextOut(10, Y, 'Printed on : '+ DateTimeToStr(Date));
     Canvas.TextOut((PageWidth- 50)- Canvas.TextWidth('Page : '+ IntToStr(PageNumber)),
                                                      Y, 'Page : '+ IntToStr(PageNumber));
     Y := Y+ Canvas.TextHeight('Yy')+ 40;
     Canvas.Font.Size := 12;
     Canvas.Font.Style := [];
     for iLoop1 := 0 to memo1.Lines.Count- 1 do
     begin
        Canvas.TextOut(10, Y, memo1.Lines[iLoop1]);
        Y := Y+ Canvas.TextHeight('Yy')+ 10;
        if Y > PageHeight- (Canvas.TextHeight('Yy')* 4) then NewPage;
     end;
     EndDoc;
  end;
end;

Hope this is of some help.

For further info also see the article by Peter McHardie
"Printing Reports without ReportSmith" in the July issue
of "The Delphi Connection". www.pennant.com/delphi.html

Regards from Ian.
--
                     ||||||||
                     | ~  ~ |
                    (| @  @ |)
----------------oOOo---(__)---oOOo------------------------
| Ian - "Smoke me a kipper I'll be back for breakfast !" |
|                                                        |
| EMail IanMa...@breallon.demon.co.uk    Banco Real s.a. |
|                                        (London Branch) |
----------------------------------------------------------

Other Threads