Multipage Printing - How do I Implement It?

Discussion in 'MCSD' started by Nigel, Aug 15, 2003.

  1. Nigel

    Nigel Guest

    The Visual Basic .NET Step by Step book has the following code and text:

    Imports System.Drawing.Printing

    Private Sub PrintText(ByVal sender As Object, ByVal ev As
    PrintPageEventArgs)
    ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", 11,
    FontStyle.Regular), Brushes.Black, 120, 120)
    ev.HasMorePages = False
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Button2.Click
    Try
    Dim PrintDoc As New PrintDocument()
    AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
    PrintDoc.Print()
    Catch ex As Exception
    MessageBox.Show("Sorry--there is a problem printing", ex.ToString())
    End Try
    End Sub

    This code only prints one page. The book states "To handle multipage
    printouts, you need to create a virtual page of text called the PrintPage,
    and then add text to it until the page is full. When the page is full, it
    will be sent to the printer and this process continues until there is no
    more text to print. At this point, the print job ends."

    "The PrintPage event occurs when a page is printed. PrintPage receives an
    argument of the type PrintPageEventArgs, which provides you with the
    dimensions and characters of the current printer page. Another mechanism is
    the Graphics.MeasureString method which can be used to determine how many
    characteristics & lines can fit in a rectangular area of the page"

    I tried looking for information on how to implement this but found now. How
    do I implement MultiPage printing?

    Not only do I want to know how to multipage print using the PrintDocument
    class I also do not want to use Crystal Reports or pdf for report generation
    in the web browser in order to print reports from web browser. I saw the
    microsoft MCP website used an ActiveX control to print your MCP Transcript.
    That's exactly what I want. To pull information from an SQL Server database
    and bulid mu own print page/s with the text and graphics I want on it so I
    can have my report.
    Nigel, Aug 15, 2003
    #1
    1. Advertising

  2. Nigel

    Maria Guest

    Printing complex multi page documents is not exactly a
    trivial task except maybe for straight text. To do it
    properly you will need to work with the print caps of
    whatever default printer the user has installed - if any.

    It may be worthwhile to check out the Microsoft Office
    toolkit. Perhaps it's possible to have an Excel template
    doc, fill it with data on the fly and send it to the
    user's printer, letting Office handle the complexities of
    paper size/orientation, headers and footers. After all
    Office apps claim that they make it easy to generate web
    pages...

    Here is the office 2000 ResKit home page:
    http://www.microsoft.com/office/ork/2000/default.htm
    Maria, Aug 16, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PA

    MultiPage Image file

    PA, Dec 29, 2004, in forum: Digital Photography
    Replies:
    2
    Views:
    311
    RSD99
    Dec 29, 2004
  2. Ralf Schmode
    Replies:
    5
    Views:
    950
  3. elie
    Replies:
    0
    Views:
    930
  4. elie
    Replies:
    0
    Views:
    861
  5. elie
    Replies:
    0
    Views:
    918
Loading...

Share This Page