[DUG] Print Preview
John Bird
johnkbird at paradise.net.nz
Fri Nov 25 15:38:30 NZDT 2005
The reason I want to see the printer canvas is the usual reason for wanting
to see a print preview - what I am sending to the printer is NOT the same as
the original form, I have added headers, and omitted some items, tweaked
font sizes etc, so that is what I want to see. At present I am running to
the laser printer too much!
>From the documentation and tests I did the scaling is handled by the
different sizes of the rects in copyrect, yes of course the printer canvas
and form canvas are greatly different sizes (eg 800x600 vs 2400x3171 for
300 DPI to A4)
The code I am using for printing adds items to Printer.Canvas one by one,
using Printer.canvas.textout, so I was assuming I could copy back from the
printer canvas similarly, but grab the whole rect.
A related question is how come Windows never provided a print preview as
part of printing?
John
-----Original Message-----
From: Kyley Harris [mailto:kyleyharris at gmail.com]
Sent: Friday, 25 November 2005 3:13 p.m.
To: johnkbird at paradise.net.nz; NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Print Preview
It boggles me why you would do that?
Surely you have a source that you are sending to the Printer Canvas?
simply place that source onto another
canvas? Why try and read from output when you have the original?
Also. Don't forget that your printer canvas is going to be 200-300-600dpi
or anything. You need to scale
your information correctly if you want to see anything useful.
If you have code that prints to a canvas, just make sure the code is using
regions defined by the inclusion
of X and Y DPI modifiers.
for my report engine I use Points as the unit of measurement, the same as
PDF. When I am drawing to a preview I
just set the DPI to 96 (screen.pixelsperinch) if I want a 50% view i set
DPI to 48. 200% is 192dpi etc. Some fonts wont scale well. All
measuremeents will be Size*DPI/72 (72 is points per inch)
so, even if you could copy off a canvas, you shouldn't. the results would
be undesirable.
On Fri, 25 Nov 2005 14:56:38 +1300, John Bird <johnkbird at paradise.net.nz>
wrote:
> Was experimenting with adding a print preview by copying from the
> Printer.canvas to a form.canvas and showing it
>
> PrintRect,PreviewRect:TRect;
> begin
> duPageWidth:=GetDeviceCaps(Printer.Canvas.Handle,PHYSICALWIDTH);
>
> duPageHeight:=GetDeviceCaps(Printer.Canvas.Handle,PHYSICALHEIGHT);
>
> //show this page with copyrect command
> PrintRect:=Rect(10,10,duPageWidth-20,duPageHeight-20);
>
PreviewRect:=Rect(10,10,frmjkblPrint.Width-20,frmjkblPrint.Height-20);
> frmjkblPrint.Canvas.CopyRect(PreviewRect,Printer.Canvas,PrintRect);
> frmjkblPrint.show;
>
> But it doesn't work...
> Is it legit to copyrect from Printer.canvas?
>
>
> John
>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
--
Kyley Harris
+64-21-671821
More information about the Delphi
mailing list