Print job from windows Forms

  • Thread starter Thread starter Ivan Jericevich
  • Start date Start date
I

Ivan Jericevich

Does anyone know where I can get a step-by-step walkthrough on how to Print
a document from VB Express 2005
 
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?
 
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.StreamReader... Or you could Imports
System.IO...
 
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.CreateGraphics()

Dim s As Size = Me.Size

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

Dim memoryGraphics As Graphics = Graphics.FromImage(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.PrintPageEventArgs) Handles _

PrintDocument1.PrintPage

e.Graphics.DrawImage(memoryImage, 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.EventArgs) Handles BtnPrint.Click

CaptureScreen()

Dim PrintDialog1 As New PrintDialog()

PrintDialog1.Document = PrintDocument1

Dim result As DialogResult = PrintDialog1.ShowDialog()

If (result = DialogResult.OK) Then

PrintDocument1.Print()

End If

End Sub
 
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.sourceforge.net/>
and copy the image into the document...
 
Back
Top