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.

thank you       

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to