Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Printing, wrapping text, pagination, etc.

Printing, wrapping text, pagination, etc.

Scheduled Pinned Locked Moved C#
question
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kyledunn
    wrote on last edited by
    #1

    Anyone know of any good articles on printing, wrapping text and pagination, etc.? Kyle

    P 1 Reply Last reply
    0
    • K kyledunn

      Anyone know of any good articles on printing, wrapping text and pagination, etc.? Kyle

      P Offline
      P Offline
      Peter Stephens
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • P 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

        K Offline
        K Offline
        kyledunn
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • K kyledunn

          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

          P Offline
          P Offline
          Peter Stephens
          wrote on last edited by
          #4

          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

          K 1 Reply Last reply
          0
          • P 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

            K Offline
            K Offline
            kyledunn
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups