Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Vb.Net Problem - Printing Multiple Pages

isocam
Collaborator

Vb.Net Problem - Printing Multiple Pages

isocam
Collaborator
Collaborator

Can anybody help?

 

I have create a string of text, in a variable called "TempString". I know, if I was to print this string of text using Notepad, it would print out several pages.

 

However, I am using the following Vb.Net code, shown below, to print the string of text  the default printer.

 

The problem is that it only ever prints out one page only, not several as expected.

 

Does anybody know is wrong with the following code?

 

Public Sub PrintTextFile()
Dim prn As New Printing.PrintDocument

Using (prn)
prn.PrinterSettings.PrinterName = "\\USFS-02\HPM479_5"

AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler

prn.Print()

RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler
End Using
End Sub

 

Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs)
Dim myFont As New Font("Lucida Console", :smiling_face_with_sunglasses:

args.Graphics.DrawString(TempString, New Font(myFont, FontStyle.Regular), Brushes.Black, 50, 50)
End Sub

 

Many thanks in advance!

 

Darren

0 Likes
Reply
112 Views
0 Replies
Replies (0)