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. How to use PrintDocument

How to use PrintDocument

Scheduled Pinned Locked Moved C#
tutorialquestion
7 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.
  • D Offline
    D Offline
    DPaul1994
    wrote on last edited by
    #1

    I have created a form in a tabcontrol -> tabpage, it has a contract format and I need to print it. So, I heard about PrintDocument but I don't really know how should I use it to print a tabpage because it has a large height and it should be printed on multiple pages. Any suggestions please? Thanks

    OriginalGriffO 1 Reply Last reply
    0
    • D DPaul1994

      I have created a form in a tabcontrol -> tabpage, it has a contract format and I need to print it. So, I heard about PrintDocument but I don't really know how should I use it to print a tabpage because it has a large height and it should be printed on multiple pages. Any suggestions please? Thanks

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      That's what a PrintDocument is for - it allows you to select exactly what is printed, and where it is printed, in what font, what colours, etc. What it doesn't do is "print a control" such as a tap page - because that's silly. The control is very unlikely to conform to the form factor of the paper being printed onto (and it'll have a "screen based" resolution rather than a "printout based" resolution, which is generally a lot, lot higher. Have a look at the documentation: https://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(v=vs.110).aspx[^] - it includes a simple example.

      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      D 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        That's what a PrintDocument is for - it allows you to select exactly what is printed, and where it is printed, in what font, what colours, etc. What it doesn't do is "print a control" such as a tap page - because that's silly. The control is very unlikely to conform to the form factor of the paper being printed onto (and it'll have a "screen based" resolution rather than a "printout based" resolution, which is generally a lot, lot higher. Have a look at the documentation: https://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(v=vs.110).aspx[^] - it includes a simple example.

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

        D Offline
        D Offline
        DPaul1994
        wrote on last edited by
        #3

        Well, which is the right way to print a form with textboxes, labels in a specific location in form? In that example it prints a text file. But in that way, it prints the whole windows form. Or, is there any third way? For example to send data in a word document?

        OriginalGriffO 1 Reply Last reply
        0
        • D DPaul1994

          Well, which is the right way to print a form with textboxes, labels in a specific location in form? In that example it prints a text file. But in that way, it prints the whole windows form. Or, is there any third way? For example to send data in a word document?

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Why would you want to print text boxes? Do you expect the user to type in them? :laugh:

          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          D 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Why would you want to print text boxes? Do you expect the user to type in them? :laugh:

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

            D Offline
            D Offline
            DPaul1994
            wrote on last edited by
            #5

            No, I mean the shape of textbox..I have to print a specific design of the form, as I said, its format is as a contract..it's not just some simple text..

            OriginalGriffO 1 Reply Last reply
            0
            • D DPaul1994

              No, I mean the shape of textbox..I have to print a specific design of the form, as I said, its format is as a contract..it's not just some simple text..

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              If you look at the example, it draws the text via the DrawText method of the Graphics object. A quick look at the documentation would show you there are a lot of other Draw... methods. Including lines, rectangles, circles, paths, images, filled and unfilled. So if you want a form with boxes for the user to write in, then DrawRectangle is probably a good place to start...

              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              D 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                If you look at the example, it draws the text via the DrawText method of the Graphics object. A quick look at the documentation would show you there are a lot of other Draw... methods. Including lines, rectangles, circles, paths, images, filled and unfilled. So if you want a form with boxes for the user to write in, then DrawRectangle is probably a good place to start...

                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                D Offline
                D Offline
                DPaul1994
                wrote on last edited by
                #7

                Ok then, it seems that this is the solution. Thank you for your time and help.

                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