Re: How to print in full page without margins



Hi Ron,
I found a great set of codes and article that you post in the other forum
for getting the printer's hard margin throught GetDeviceCaps.

I was able to retrieve the correct hard margins through GetDeviceCaps but I
am unable to tell the printer to use that hard margins to draw maximum
printable area. I have the following code for setting the margins.

IntPtr hDc = new IntPtr();
hDc = e.Graphics.GetHdc();
PrintUtil.GetHardMargins(hDc, ref leftHardMargin, ref topHardMargin, ref
rightHardMargin, ref bottomHardMargin);
e.Graphics.ReleaseHdc(hDc);



leftMargin = Convert.ToInt32(leftHardMargin);
topMargin = Convert.ToInt32(topHardMargin);
rightMargin = Convert.ToInt32(rightHardMargin);
bottomMargin = Convert.ToInt32(bottomHardMargin);

this.DefaultPageSettings.Margins = new
Margins(leftMargin,leftMargin,topMargin,topMargin);

this.OriginAtMargins = true;
Rectangle myRect = new Rectangle(leftMargin, topMargin, rightMargin,
bottomMargin);


e.Graphics.DrawRectangle(Pens.Black, myRect );

The printer cuts of the right side of the rectangle box. And the printer's
left offeset seems to be wider than the printer's actual printable area which
I tested with left and right margin set to zero. So I can see where the
printer start printing on the page.

I have tried so many ways of setting printers margins but none seems to work.

Furthermore, my way of setting margins have different effects on different
printers.

Please help me figure out what is making this weird behavior.

Thanks in advance


"Ron Allen" wrote:

> Most printers can't print all the way to the physical margins. You are
> undoubtedly seeing the physical offset for the hard margins for your page.
> You can PInvoke GetDeviceCaps to get the exact physical margins for the
> printer drawing on a page and you could then scale the drawing so that all
> your information will fit or just offset things if you don't need the actual
> whole page size.
> There are some printers that can print all the way to the margins for
> larger paper but they tend to be very expensive.
>
> Ron Allen
> "zhaounknown" <zhaounknown@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:AB95B24B-D809-4833-B4E7-AC6219F114D4@xxxxxxxxxxxxxxxx
> >I set the DefaultPageSettings.Margins.Left/Right/Top/Bottom to 0, it
> >doesn't
> > seem to work for the Left margin for two printers (HP and Brother).
> >
> > Am I missing any other properties that should be set? Thanks a lot.
>
>
>
.



Relevant Pages

  • Re: This Lispofobics really gone too far
    ... using a word processor. ... most people didn't have access to high-quality printers ... > single-space. ... > margins are totally fine. ...
    (comp.lang.lisp)
  • Re: [SLE] Envelopes in OpenOffice
    ... > margins for the DL size. ... works only with certain types of printers, ... How on earth do I print landscape envelopes? ... DL portrait or landscape, but it is as if I'm talking to the wall. ...
    (SuSE)
  • Centering pages for print in Word 2003...
    ... otherwise I shall have to request the printers to solve this problem ... My left & right margins are close to perfect. ... So far as I can tell, the problem may lie in my headers & ... footers, which I am so far unable to push up & down within the ...
    (microsoft.public.word.formatting.longdocs)
  • Re: Watermark Picture Letterhead and Margin problem
    ... margins nor do margins have any bearing on it. ... most printers impose minimum margin settings which Word cannot ... watermark picture and adjusted it to cover the entire page. ...
    (microsoft.public.word.pagelayout)
  • Re: How to print in full page without margins
    ... TranslateTransform by the negative of the left and top margins and then draw ... the drawing as well. ... > bottomMargin = Convert.ToInt32; ... > I have tried so many ways of setting printers margins but none seems to ...
    (microsoft.public.dotnet.framework.drawing)