Getting unprintable margin for a printer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to find a .Net way to get the unprintable margin for a printer. I know I could link to the SDK function GetDeviceCaps, but, I wanted to make sure there wasn't a cleaner way

TIA
Dave
 
You could use the PrinterSettings class and probably the PrintDocument
class. I am not sure which "defaults" are used to initialize the fields of a
PrinterSettings instance though. Hope these are those retrieved from
GetDeviceCaps behind the scenes.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Dave said:
I'm trying to find a .Net way to get the unprintable margin for a printer.
I know I could link to the SDK function GetDeviceCaps, but, I wanted to make
sure there wasn't a cleaner way.
 
Dave,
That's the only way I know of. IF the margins are symmetrical, you
could compare VisibleClipBounds Width/Height to the page properties and use
1/2 the difference. This would work on a lot of laser printers but still
wouldn't be accurate.

Ron Allen
Dave said:
I'm trying to find a .Net way to get the unprintable margin for a printer.
I know I could link to the SDK function GetDeviceCaps, but, I wanted to make
sure there wasn't a cleaner way.
 
Dave,
Also, if you are using Framework 1.1 you can use the OriginAtMargins
property of the PrintDocument. If you set this to true your Graphics origin
will be just inside the Margins setting of the document, i.e. 1"/1" by
default. If you normally use printouts with a wide margin setting this
should work just fine for you.
I still use GetDeviceCaps because I need to check to see if the page
fits inside the printable area of the printer. I scale to fit if it doesn't
and just use TranslateTransform to compensate for the hard margins.

Ron Allen
Dave said:
I'm trying to find a .Net way to get the unprintable margin for a printer.
I know I could link to the SDK function GetDeviceCaps, but, I wanted to make
sure there wasn't a cleaner way.
 
Back
Top