A while back I had a similar problem displaying a logo on a print out. I ended using StrectchDraw cause I knew the size of the output I wanted. It went somthing like this. (Might be of some help)
 
// Get the number of pixels along the X and Y axis 
  FPixInInchX := GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSX);
  FPixInInchY := GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY);
 
      R := Rect(0, 0, FPixInInchX , FPixInInchY); // print logo in top left corner one inch square
      with Printer.Canvas do
        StretchDraw(R,myBitmap);
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Robert Martin
Sent: Wednesday, July 04, 2001 12:01 PM
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Printing

Does any one have any suggestions, we are stumped?
 
Rob
Software engineer
Wild Software Ltd
[EMAIL PROTECTED]
----- Original Message -----
Sent: Tuesday, July 03, 2001 3:02 PM
Subject: [DUG]: Printing

I have a program where I want to draw a number of Rectangles on a TCanvas, I then want to use CopyRect to copy page sized blocks of the source canvas to the Printers canvas.  This will, I hope, give me a simple way of outputting multiple pages from my layout application.
 
The problem is I get no output at all, the printer whirrs and stops.  I was getting good output by drawing directly to the printers canvas, and suspect the problem lies with copyrect.  I have setup the following test code and determined that if I load my source canvas with an image (loadFromFile) the copyrect works fine, If instead I draw to the canvas of the image copyRect fails.  Is their a step I am missing?
 
    MaxPos := 0;
 
    with Printer do begin
        BeginDoc;
        try
            Title := 'Image Layout';
 
            //build Canvas
            Image := TImage.Create(Application);
 
            try
              //Draw on canvas
              SourceRect  := Rect(0, 0, 10000, 10000);
              DestRect    := Rect(0, 0, 10000, 10000);
 
              Image.Canvas.Rectangle(1, 1,  200 , 200);
              
              Canvas.CopyMode := cmSrcCopy;
              Canvas.CopyRect (DestRect, Image.Canvas, SourceRect);
            finally
               Image.Free;
            end;
        finally
           EndDoc;
        end;
    end;
 
 
 
Please excuse the alignement etc of the above code.  Note that if I replace 'Image.Canvas.Rectangle(1, 1,  200 , 200);' with a loadfromfile an output is acheived.  I have viewed the image on screen and can confirm a rectangle is displayed.
 
Any help would be greatly appreciated.
 
Rob
Software engineer
Wild Software Ltd
[EMAIL PROTECTED]

Reply via email to