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. Visual Basic
  4. Print several pages

Print several pages

Scheduled Pinned Locked Moved Visual Basic
questioncsharpgraphics
3 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.
  • M Offline
    M Offline
    Marc Soleda
    wrote on last edited by
    #1

    hi all, I'm playing with the PrintDialog, PrintPreviewDialog and PrintDocument (VB2005 & .Net2.0) so I'm building the document to print on runtime: the user choose some parameters and then the program must print a list of the ones that fits the params. The PrintDocument is build when the PrintDocument1_PrintPage event occurs and by inserting Strings and Lines through e.Graphics.DrawString and e.Graphics.DrawLine commands. That's fine (quite tough X|) but I can't manage to add more pages to the document to print. How do I force a new page to fill with data so the document to print would have more than one page? I haven't found the way for changing the page :confused:!!! Thanks in advance, Marc Soleda

    ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

    A 1 Reply Last reply
    0
    • M Marc Soleda

      hi all, I'm playing with the PrintDialog, PrintPreviewDialog and PrintDocument (VB2005 & .Net2.0) so I'm building the document to print on runtime: the user choose some parameters and then the program must print a list of the ones that fits the params. The PrintDocument is build when the PrintDocument1_PrintPage event occurs and by inserting Strings and Lines through e.Graphics.DrawString and e.Graphics.DrawLine commands. That's fine (quite tough X|) but I can't manage to add more pages to the document to print. How do I force a new page to fill with data so the document to print would have more than one page? I haven't found the way for changing the page :confused:!!! Thanks in advance, Marc Soleda

      ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

      A Offline
      A Offline
      Ajay k_Singh
      wrote on last edited by
      #2

      For starting a new page, you will need to set e.HasMorePages property to True and exit the PrintPage event. If this property is set to true while exiting sub, this event will be called again and its content will be printed on the next page. Therefore it should be something like – e.HasMorePages = True Exit Sub Please remember that you will need to track manually when this event is being called for the second time and what you need to print on the second page. This can be done using a global variable. Such as – ----------------------Code Start--------------- Dim PageCount As Integer = 1 Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage If PageCount = 1 Then ''''Code to print on first page e.HasMorePages = True PageCount += 1 Exit Sub ElseIf PageCount = 2 Then ''''Code to print on Second Page e.HasMorePages = True PageCount += 1 Exit Sub End If End Sub ------------------Code End------------------- In the similar way you may create any number of new pages. I hope this helps :) . -Dave.

      Dave Traister, ComponentOne LLC. www.componentone.com

      M 1 Reply Last reply
      0
      • A Ajay k_Singh

        For starting a new page, you will need to set e.HasMorePages property to True and exit the PrintPage event. If this property is set to true while exiting sub, this event will be called again and its content will be printed on the next page. Therefore it should be something like – e.HasMorePages = True Exit Sub Please remember that you will need to track manually when this event is being called for the second time and what you need to print on the second page. This can be done using a global variable. Such as – ----------------------Code Start--------------- Dim PageCount As Integer = 1 Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage If PageCount = 1 Then ''''Code to print on first page e.HasMorePages = True PageCount += 1 Exit Sub ElseIf PageCount = 2 Then ''''Code to print on Second Page e.HasMorePages = True PageCount += 1 Exit Sub End If End Sub ------------------Code End------------------- In the similar way you may create any number of new pages. I hope this helps :) . -Dave.

        Dave Traister, ComponentOne LLC. www.componentone.com

        M Offline
        M Offline
        Marc Soleda
        wrote on last edited by
        #3

        Great, it's what I was looking for. Thanks, Marc Soleda

        ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

        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