Hey Jeff, In V1.0 of the .Net framework, Microsoft did not take account for the hard margins of the printer. This means that if the hard margin for the printer was inset by 1/4 of an inch then a margin of 1 inch would actually be inset by 1.25 inches. Nice huh? :)
In V1.1 of the framework, they have added an OriginAtMargins property that when true will take the hard margin into account when setting the actual margin so that the margin is physically 1 inch from the edge of the printer. You will probably have to pinvoke to get the offset you require to re-adjust your placement of objects. Jim > From: Jeff Roberts <[EMAIL PROTECTED]> > Subject: Advanced printing with GDI+ > > I have posted this on the WIN_FORMS list and gotten > no reply, can someone please help ? > > I am porting an advanced printing application from > win32 MFC C++ to C# .NET. I am having trouble > positioning text on a printed page at a specific > location. My application supports margins and > prints in the Graphics.PageUnit Pixel mode. My > application uses the page dimensions in pixels, the > horizontal and vertical resolutions, and the > Graphics.MarginBoundries to determine where to start > printing on the page. The code is ported from win32 > and calculates the X,Y location properly, however, > the printout always gets shifted about 2/16 of an > inch. For example, my printer has a horizontal > resolution of 300 dpi, the MarginBounds.Left > property (area unprintable on left side of page) is > 100, if I do a DrawString at location 200,200, then > I would expect the string to be printed exactly 1 > inch (300 pixels) from the left side of paper. It > is always prints 1 2/16 of an inch from the left > side of the paper ! WHY ? When I do the same > thing under WIN32, it prints exactly 1" from the > left. > > private void PrintLine(string s,PrintEventArgs ev) > { > ev.Graphics.PageUnit = GraphicsUnit.Pixel; > ev.Graphics.TextRenderingHint = TextQuality; > ev.Graphics.PixelOffsetMode = > PixelOffsetMode.None; > > StringFormat drawFormat = new > StringFormat(); > drawFormat.Alignment = StringAlignment.Near; > > ev.Graphics.DrawString(s, printFont, > ForgroundColor, 200,200, drawFormat); > } > > Any help would be greatly appreciated, I am ready to > toss the printer out the window ! I have tried > everything. __________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.