| View previous topic :: View next topic |
| Author |
Message |
akeix Member
Joined: 14 Jan 2004 Posts: 3
|
Posted: 14/01/04 14:24 Post subject: [TPrintPreview]Margin Of Printer |
|
|
I'm French. Excuse-me for my english language.
How i can to have the margin minimun for to print with the component TPrintPreview ?
Thank You.
Akeix |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 412 Location: Tehran, Iran
|
Posted: 14/01/04 15:16 Post subject: |
|
|
PrintPreview does not have any method/property for this purpose.
| Code: | Offset.X := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);
Offset.Y := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY); |
|
|
| Back to top |
|
 |
akeix Member
Joined: 14 Jan 2004 Posts: 3
|
Posted: 14/01/04 19:28 Post subject: |
|
|
Ok
But, if the resolution of printer is different of the resolution of screen.
For example :
My printer = 300 DPI,
and my screen (and PrintPreview) = 72 DPI.
Thank you
Akeix |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 412 Location: Tehran, Iran
|
Posted: 14/01/04 21:00 Post subject: |
|
|
| You can use ConvertUnits procedure for converting the values. |
|
| Back to top |
|
 |
aspence Member
Joined: 11 Jul 2004 Posts: 13 Location: Wolfville, N.S. Canada
|
Posted: 11/07/04 10:25 Post subject: |
|
|
This had me stumped for a bit too. To elaborate on the reply from Kambiz, I've written the following function:
| Code: |
function GetPrintable: TRect;
begin
with PrintPreview do
begin
result.Left := ConvertUnits(GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX),
GetDeviceCaps(Printer.Handle, LOGPIXELSX),
mmPixel, Units);
result.Top := ConvertUnits(GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY),
GetDeviceCaps(Printer.Handle, LOGPIXELSY),
mmPixel, Units);
result.Right := result.Left + ConvertUnits(Printer.PageWidth,
GetDeviceCaps(Printer.Handle, LOGPIXELSX),
mmPixel, Units);
result.Bottom := result.Top + ConvertUnits(Printer.PageHeight,
GetDeviceCaps(Printer.Handle, LOGPIXELSY),
mmPixel, Units);
end;
end;
|
This code will handle cases where the printer x and y DPI are not the same. It will also handle cases where the printable area is not centered on the page (such as my printer, an Epson Stylus C60). Once you have the printable rectangle, all of your drawing to the preview should be kept within these boundaries. Incidentally, Printer.PageWidth and Printer.PageHeight represent the width and height of the printable area.
Since this code queries the printer itself, it's important that the printer settings reflect what is going on with the PrintPreview (your PrintPreview may be in Portrait mode when the printer is in landscape mode) so call PrintPreview.SetPrinterOptions before calling this function. _________________ - Arnold B. Spence |
|
| Back to top |
|
 |
akeix Member
Joined: 14 Jan 2004 Posts: 3
|
Posted: 07/08/04 06:29 Post subject: |
|
|
| Thank You ! |
|
| Back to top |
|
 |
Justino Member
Joined: 19 Dec 2004 Posts: 1
|
Posted: 19/12/04 22:23 Post subject: |
|
|
PrintPreview.PrinterPageBounds Rect does the same for me.
Nice site, good components.
I'm having troubles with margins, but that's kinda normal when working with the printer. A lot of old printers can't even get the paper properly feeded. I'm starting to dislike programming printing stuff.. luckily you helped me making most part of the program. Thanks, from Holland. |
|
| Back to top |
|
 |
|