Finding the printable area?

  • Thread starter Thread starter Steve Podradchik
  • Start date Start date
S

Steve Podradchik

Hi,

Our app likes to print data-rich output that fills the page width of the
printer. Unfortunately, we've found that the printable area of each printer
is a little different, making it a bit of a guess to set the left/right
print margins which seem additive to the printable area start. I don't
believe that .Net directly supports providing the printable area but I seem
to remember someone, > 1 year ago, posting some C code to find the printable
area. Any ideas? Or did I miss something in .Net?

Thanks, Steve
 
Hi Steve,

Thanks for your post. As I understand, you want to get margins information
for your printer in .NET. Please correct me if there is any
misunderstanding.

Please refer to the Margins property of PageSettings class which enables us
to get or set the margins information. Please refer to the following MSDN
article:

PageSettings.Margins Property
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdrawingprintingpagesettingsclassmarginstopic.asp

For more classes regarding print-related services, please refer to
System.Drawing.Printing Namespace:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdrawingprinting.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Steve,
You will need to use PInvoke on GetDeviceCaps to find the exact margins.
In version 1.1 you can set a property in PageSettings to start the origin at
the margins vs. the physical boundary but that doesn't tell you the size of
the physical printable area. Just get your hDC from the graphics and call
GetDeviceCaps to check sizes. If you would like some C# code for this let
me know.

Ron Allen
 
Back
Top