Printing, wrapping text, pagination, etc.
-
Try www.gotdotnet.com. They have some useful articles on GDI+. From my experience I would recommend using GraphicsUnit.Document (1/300 inch) as a scale mode. I tried using pure inches and encountered terrible roundoff errors in the GDI matrix transformations. One issue I was not able to overcome with managed code was the printer's page offset. (0,0) is at the upper left corner in the print preview, but offset by some arbitrary amount when printing (presumably different for each printer.) This information can be found out with Win32, but seemingly not with Managed Code. :( -- Peter Stephens
-
Try www.gotdotnet.com. They have some useful articles on GDI+. From my experience I would recommend using GraphicsUnit.Document (1/300 inch) as a scale mode. I tried using pure inches and encountered terrible roundoff errors in the GDI matrix transformations. One issue I was not able to overcome with managed code was the printer's page offset. (0,0) is at the upper left corner in the print preview, but offset by some arbitrary amount when printing (presumably different for each printer.) This information can be found out with Win32, but seemingly not with Managed Code. :( -- Peter Stephens
Because I also had trouble with inches and printers have default page units of GraphicsUnit.Display that is what I am using. Your recommendation seems to make more sense as it offers finer control so I think I will give it a try. I'll also check out the gotdotnet articles. Thanks. Would you like the unmanaged code in C# to obtain the unprintable margins? I can copy and post it for you if you need it. Thanks again, Kyle
-
Because I also had trouble with inches and printers have default page units of GraphicsUnit.Display that is what I am using. Your recommendation seems to make more sense as it offers finer control so I think I will give it a try. I'll also check out the gotdotnet articles. Thanks. Would you like the unmanaged code in C# to obtain the unprintable margins? I can copy and post it for you if you need it. Thanks again, Kyle
I'm not currently working on printing, but I will probably do some in the future. So sure, if you have the Unmanaged Code handy, I can store it for future reference... ;) Thank you -- Peter Stephens
-
I'm not currently working on printing, but I will probably do some in the future. So sure, if you have the Unmanaged Code handy, I can store it for future reference... ;) Thank you -- Peter Stephens
Here's the code: // Reference InteropServices; using System.Runtime.InteropServices; // define constants for the physical offset values private const int PHYSICALOFFSETX = 112; private const int PHYSICALOFFSETY = 113; // Define DLL and prototype the Win32 API method [DllImport("gdi32")] public static extern int GetDeviceCaps(IntPtr hdc, int cap); // get the device context handle from the graphic object that is being printed // call GetDeviceCaps to return the offsets // release the handle to the device context int unprintableleft, unprintabletop; IntPtr hdc; hdc = e.Graphics.GetHdc(); unprintableleft = GetDeviceCaps(hdc,PHYSICALOFFSETX); unprintabletop = GetDeviceCaps(hdc,PHYSICALOFFSETY); e.Graphics.ReleaseHdc(hdc); MessageBox.Show("Unprintable: " + unprintableleft + " " + unprintabletop); Kyle