Printing Example

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pitaridis Aristotelis

    #1

    Printing Example

    Is there a complete example of how to print, print preview, change print
    settings, etc. in VB.NET.



    Aristotelis


  • Pace

    #2
    Re: Printing Example

    Hi,

    There is a great tutorial you may find useful here;


    On 5 Dec, 07:49, "Pitaridis Aristotelis" <pitari...@hotm ail.comwrote:
    Is there a complete example of how to print, print preview, change print
    settings, etc. in VB.NET.
    >
    Aristotelis

    Comment

    • Stuart Nathan

      #3
      Re: Printing Example

      Actually, I don't think it is very helpful as it doesn't really explain the
      mechanisms going on. I have had a lot of printing problems because the VB
      Help file is unhelpful and I have found nowhere on the net that properly
      explains printing, and if it tries to, it makes too many assumptions.

      Effectively what happens is this.

      You need to create a PrintDocument
      Dim Withevents MyDoc as Drawing.Printin g.PrintDocument
      the withevents automatically will create the PrintPage event.
      This event has a PrintPageEventA rgs argument which is used to print to, and
      you use it by using its .Graphics property to print to, just as you would
      when painting a control (using GDI).
      Once you finish painting your page, you then use the args.HasMorePag es which
      can be set False if no more printing or True if you have more to print.
      If True, the PrintPage event is raised again and you continue painting the
      next by now cleared page. You loop through this event until you have no more
      page painting to do and then you set the args.HasMorePag es = False,
      otherwise you will simply print a blank page.
      Once you have finished painting, you can use the MyDoc.Print() to print it,
      or if you wish to show it in a PrintPreview by using its .Document=myDoc

      The PrintDocument uses you default page settings which you get to and change
      by using the MyDoc.DefaultPa geSettings
      You will need to access these properties as it will then tell you your
      margins etc. Remember that when painting the document, you may use
      args.Graphics.D rawString() and you will need to set the x and y locations.

      However I have a problem in that I can't find a way of replacing the
      previously loaded document in the print preview with a new.

      I hope this helps.


      Comment

      • Stuart Nathan

        #4
        Re: Printing Example

        And the answer to that is Preview.Invalid atePreview


        Comment

        • Pitaridis Aristotelis

          #5
          Re: Printing Example

          I know that this is very easy for you. Can someone put all this into a
          working project and send it to me in order to understand it better.

          My email is pitaridis@hotma il.com

          Thanks

          Ï "Stuart Nathan" <stuart.nathan@ homecall.co.ukÝ ãñáøå óôï ìÞíõìá
          news:%23CqMSCJG HHA.1216@TK2MSF TNGP05.phx.gbl. ..
          >
          And the answer to that is Preview.Invalid atePreview
          >

          Comment

          Working...