Print job from windows Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ivan Jericevich

    #1

    Print job from windows Forms

    Does anyone know where I can get a step-by-step walkthrough on how to Print
    a document from VB Express 2005


  • Tim Van Wassenhove

    #2
    Re: Print job from windows Forms

    Ivan Jericevich schreef:
    Does anyone know where I can get a step-by-step walkthrough on how to Print
    a document from VB Express 2005

    How hard have you searched already? A simple websearch on 'Print job
    from windows Forms Visual Basic' returned
    http://msdn2.microsoft.com/en-us/lib...he(VS.80).aspx as the
    second link.


    --
    Tim Van Wassenhove <url:http://www.timvw.be/>

    Comment

    • Ivan Jericevich

      #3
      Re: Print job from windows Forms

      Thank you Tim, I have copied the code from your source but have only one
      problem. 2 Errors both- Type 'StreamReader' is not defined.
      What am I missing?

      "Tim Van Wassenhove" <timvw@users.so urceforge.netwr ote in message
      news:eGkIcD7RHH A.3412@TK2MSFTN GP02.phx.gbl...
      Ivan Jericevich schreef:
      >Does anyone know where I can get a step-by-step walkthrough on how to
      >Print a document from VB Express 2005
      >
      >
      How hard have you searched already? A simple websearch on 'Print job from
      windows Forms Visual Basic' returned
      http://msdn2.microsoft.com/en-us/lib...he(VS.80).aspx as the
      second link.
      >
      >
      --
      Tim Van Wassenhove <url:http://www.timvw.be/>

      Comment

      • Tim Van Wassenhove

        #4
        Re: Print job from windows Forms

        Ivan Jericevich schreef:
        Thank you Tim, I have copied the code from your source but have only one
        problem. 2 Errors both- Type 'StreamReader' is not defined.
        What am I missing?
        StreamReader is short for System.IO.Strea mReader... Or you could Imports
        System.IO...

        --
        Tim Van Wassenhove <url:http://www.timvw.be/>

        Comment

        • Ivan Jericevich

          #5
          Re: Print job from windows Forms

          Tim your just great, I have managed to capture the form as a bitmap and
          print it using the Print Dialog. Thanks for the help. Any ideas how I can
          save the same bitmap image preferably as a Pdf file and save it to a file
          folder on my c: drive. here is my code:
          Dim memoryImage As Bitmap

          Private Sub CaptureScreen()

          Dim myGraphics As Graphics = Me.CreateGraphi cs()

          Dim s As Size = Me.Size

          memoryImage = New Bitmap(s.Width, s.Height, myGraphics)

          Dim memoryGraphics As Graphics = Graphics.FromIm age(memoryImage )

          memoryGraphics. CopyFromScreen( Me.Location.X, Me.Location.Y, 0, 0, s)

          End Sub

          Private Sub printDocument1_ PrintPage(ByVal sender As System.Object, ByVal e
          As System.Drawing. Printing.PrintP ageEventArgs) Handles _

          PrintDocument1. PrintPage

          e.Graphics.Draw Image(memoryIma ge, 0, 0)

          End Sub

          Public Shared Sub Main()

          Application.Run (New FrmInvoice1())

          End Sub

          Private Sub BtnPrint_Click( ByVal sender As System.Object, ByVal e As
          System.EventArg s) Handles BtnPrint.Click

          CaptureScreen()

          Dim PrintDialog1 As New PrintDialog()

          PrintDialog1.Do cument = PrintDocument1

          Dim result As DialogResult = PrintDialog1.Sh owDialog()

          If (result = DialogResult.OK ) Then

          PrintDocument1. Print()

          End If

          End Sub


          "Tim Van Wassenhove" <timvw@users.so urceforge.netwr ote in message
          news:%23I9vTE$R HHA.3812@TK2MSF TNGP06.phx.gbl. ..
          Ivan Jericevich schreef:
          >Thank you Tim, I have copied the code from your source but have only one
          >problem. 2 Errors both- Type 'StreamReader' is not defined.
          >What am I missing?
          >
          StreamReader is short for System.IO.Strea mReader... Or you could Imports
          System.IO...
          >
          --
          Tim Van Wassenhove <url:http://www.timvw.be/>

          Comment

          • Tim Van Wassenhove

            #6
            Re: Print job from windows Forms

            Ivan Jericevich schreef:
            Tim your just great, I have managed to capture the form as a bitmap and
            print it using the Print Dialog. Thanks for the help. Any ideas how I can
            save the same bitmap image preferably as a Pdf file and save it to a file
            folder on my c: drive. here is my code:
            - Saving as an image file is easy: Simply use the Save method on the Bitmap

            - Install a PDF printer, and select that printer with your printdocument

            - Use a library like iTextSharp <url:http://itextsharp.sour ceforge.net/>
            and copy the image into the document...

            --
            Tim Van Wassenhove <url:http://www.timvw.be/>

            Comment

            Working...