page margin setting

  • Thread starter Thread starter Holly
  • Start date Start date
H

Holly

Hi, I am using framework 1.0 to implement a printing
method. The page margins I set won't show correctly on my
print out. The code is:
PageSettings pset=new PageSettings();
pset.Margins =new Margins(10,10,100,100);
printDoc.DefaultPageSettings=pset;

I have seen some explaination about
PrintDocument.OriginAtMargins property. But I am not
using the Framework 1.1. Is this the reason that the page
margins are not correct? Is there a way to implement this
in Framework 1.0?
Thanks.

Holly
 
Holly,
If you are using Framework V1.0 you will have to PInvoke GetDeviceCaps
and retrieve the 'hard margins' of the printer and then compensate for those
when you draw to the printer (I normally just call Graphics.Translate by the
appropriate amounts). A quick a dirty check to see if you are drawing to
the printer vs. a PrintPreviewDialog is to check the VisibleClipBounds. If
this is smaller than the page size you are most likely drawing to the
printer. If you'd like I have some C# code that calls GetDeviceCaps and
returns the page margins. Note that on some printers, mainly inkjets, you
may have to scale the output to get it the same as output to a laser.
Also the margins you are specifying may be too small for the printer as
0.1 inches is outside the printable area on a lot of printers.

Ron Allen
 
Back
Top