Re: How to print in full page without margins

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



SharpCoderMP. Depends on the printer. It returns correct but the printer
won't obey that margin. Thats the main problem coz it behave differently on
different printers.


"SharpCoderMP" wrote:

> how big is the difference between the size you get from code and the
> actual printed one?
>
> Judge wrote:
> > 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: How to print in full page without margins
    ... 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. ... PrintUtil.GetHardMargins(hDc, ref leftHardMargin, ref topHardMargin, ref rightHardMargin, ref bottomHardMargin); ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: How to print in full page without margins
    ... I was able to retrieve the correct hard margins through GetDeviceCaps but I ... I have tried so many ways of setting printers margins but none seems to work. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Printing Document
    ... This sounds like you have hit the 'hard margins' on the printer. ... > 3/4 inch on the right, but that seems like coding around the problem ... > Is there anything I can do besides coding the width of the report shorter? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Cant get print margins right @ printer?
    ... This is due to the 'hard margins' on the printer. ... compensate for them when drawing to the printer. ... I then translate the graphics by the desired amount -left, ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: How to change printers physical print margins thru VB coding?
    ... Margins that I have set are greater than physical margins, ... using report viewer. ... Osmotion Blue ...
    (microsoft.public.dotnet.languages.vb)