I've found the whole business of printing a graphic really confusing. I've been testing with PdfCreator and it seemed to finally be working perfectly but when I tried printing directly to my HP LaserJet, no graphic appears on the page. It was testing it with some text and some line drawing routines and they all worked perfectly but no BMP. Here's my code (and I have both Printers and PrinterStuff in my uses statement).
Thanks in advance for any ideas/answers.
procedure TReportForm.TestPrintClick(Sender: TObject);
VAR
TheWidth,TheHeight : INTEGER;
WidthStr,HeightStr : STRING;
ExecuteOk : BOOLEAN;
LogoBitMap : TBitmap;
Scale : Integer;
LeftEdge,TopRow : INTEGER;
BEGIN
ExecuteOk := PrintDialog1.Execute;
IF ExecuteOk THEN BEGIN
Printer.BeginDoc;
TheWidth := Printer.PageWidth;
TheHeight := Printer.PageHeight;
Printer.Title := 'Logo Print Test';
LogoBitMap := TBitMap.create;
LogoBitMap.LoadFromFile('RogersLogo.bmp');
Scale := Min(Printer.PageWidth div LogoBitMap.Width,
Printer.PageHeight div LogoBitMap.Height);
LeftEdge := 300;
TopRow := 600;
Printer.Canvas.MoveTo(LeftEdge,TopRow);
Printer.Canvas.StretchDraw(Rect(LeftEdge, TopRow,
LeftEdge+(LogoBitMap.Width*(Scale DIV 10)),
TopRow+(LogoBitMap.Height*(Scale DIV 10))),
LogoBitMap);
Printer.EndDoc;
LogoBitMap.Free;
end;
end;