DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[TPrintPreview]Margin Of Printer

 
   Reply to topic    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
akeix
Member


Joined: 14 Jan 2004
Posts: 3

PostPosted: 14/01/04 14:24    Post subject: [TPrintPreview]Margin Of Printer Reply with quote

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
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 412
Location: Tehran, Iran

PostPosted: 14/01/04 15:16    Post subject: Reply with quote

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
View user's profile Send e-mail Visit poster's website
akeix
Member


Joined: 14 Jan 2004
Posts: 3

PostPosted: 14/01/04 19:28    Post subject: Reply with quote

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
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 412
Location: Tehran, Iran

PostPosted: 14/01/04 21:00    Post subject: Reply with quote

You can use ConvertUnits procedure for converting the values.
Back to top
View user's profile Send e-mail Visit poster's website
aspence
Member


Joined: 11 Jul 2004
Posts: 13
Location: Wolfville, N.S. Canada

PostPosted: 11/07/04 10:25    Post subject: Reply with quote

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
View user's profile
akeix
Member


Joined: 14 Jan 2004
Posts: 3

PostPosted: 07/08/04 06:29    Post subject: Reply with quote

Thank You !
Back to top
View user's profile
Justino
Member


Joined: 19 Dec 2004
Posts: 1

PostPosted: 19/12/04 22:23    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group