Hi, I think I have my code all done except for being able to call the PrintPage procedure... I'm not sure what to put in for the "e" when calling the procedure...
Here's my code... Notice the procedure on the bottom that is trying to call the PrintPage procedure...
Here's my code... Notice the procedure on the bottom that is trying to call the PrintPage procedure...
VB.NET:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim fileStreamReader As System.IO.StreamReader = New System.IO.StreamReader(OpenFileDialog1.FileName)
If Not fileStreamReader Is Nothing Then
Do Until fileStreamReader.EndOfStream
Dim certificateHeadingFont = New Font("Times New Roman", 43, FontStyle.Regular)
Dim receiverAndCompanyFont = New Font("Times New Roman", 18, FontStyle.Bold Or FontStyle.Italic)
Dim nameAndCompanyLabelFont = New Font("Times New Roman", 14, FontStyle.Bold)
Dim DateAndInstructorAndCompany2Font = New Font("Times New Roman", 14, FontStyle.Bold)
Dim hasReceivedInstructionLabelFont = New Font("Times New Roman", 18, FontStyle.Bold)
Dim cfrFont = New Font("Times New Roman", 22, FontStyle.Bold)
Dim dateAndInstructorAndCompany2LabelFont = New Font("Times New Roman", 12, FontStyle.Regular)
Dim noticeFont = New Font("Times New Roman", 10, FontStyle.Bold)
PrintDocument1.DefaultPageSettings.Landscape = True
' Create outer border
Dim blackPen As New Pen(Color.Black, 4)
Dim point1 As New Point(40, 75)
Dim point2 As New Point(1041, 75)
Dim point3 As New Point(1041, 700)
Dim point4 As New Point(40, 700)
e.Graphics.DrawLine(blackPen, point1, point2)
e.Graphics.DrawLine(blackPen, point2, point3)
e.Graphics.DrawLine(blackPen, point3, point4)
e.Graphics.DrawLine(blackPen, point4, point1)
' Create inner border
Dim blackPen2 As New Pen(Color.Black, 2)
Dim point5 As New Point(45, 80)
Dim point6 As New Point(1036, 80)
Dim point7 As New Point(1036, 695)
Dim point8 As New Point(45, 695)
e.Graphics.DrawLine(blackPen2, point5, point6)
e.Graphics.DrawLine(blackPen2, point6, point7)
e.Graphics.DrawLine(blackPen2, point7, point8)
e.Graphics.DrawLine(blackPen2, point8, point5)
Dim x As Integer = 545
Dim y As Integer = 90
Using string_format As New StringFormat()
string_format.Alignment = StringAlignment.Center
string_format.LineAlignment = StringAlignment.Near
e.Graphics.DrawString("CERTIFICATE OF ATTENDANCE", certificateHeadingFont, Brushes.Black, x, y, string_format)
e.Graphics.DrawString(fileStreamReader.ReadLine(), receiverAndCompanyFont, Brushes.Black, x, y + 120, string_format)
e.Graphics.DrawString("NAME", nameAndCompanyLabelFont, Brushes.Black, x, y + 150, string_format)
e.Graphics.DrawString(companyTextBox.Text, receiverAndCompanyFont, Brushes.Black, x, y + 200, string_format)
e.Graphics.DrawString("COMPANY", nameAndCompanyLabelFont, Brushes.Black, x, y + 230, string_format)
e.Graphics.DrawString("has received instruction in the requirements of", hasReceivedInstructionLabelFont, Brushes.Black, x, y + 300, string_format)
e.Graphics.DrawString(cfrTextBox.Text, cfrFont, Brushes.Black, x, y + 370, string_format)
e.Graphics.DrawString(dateTextBox.Text, DateAndInstructorAndCompany2Font, Brushes.Black, 200, y + 490, string_format)
e.Graphics.DrawString("Date", dateAndInstructorAndCompany2LabelFont, Brushes.Black, 200, y + 515, string_format)
e.Graphics.DrawString(instructorTextBox.Text, DateAndInstructorAndCompany2Font, Brushes.Black, 440, y + 490, string_format)
e.Graphics.DrawString("Instructor", dateAndInstructorAndCompany2LabelFont, Brushes.Black, 440, y + 515, string_format)
e.Graphics.DrawString(company2TextBox.Text, DateAndInstructorAndCompany2Font, Brushes.Black, 740, y + 490, string_format)
e.Graphics.DrawString("Company", dateAndInstructorAndCompany2LabelFont, Brushes.Black, 740, y + 515, string_format)
e.Graphics.DrawString(extraInfoTextBox.Text, noticeFont, Brushes.Black, x, y + 589, string_format)
End Using
' Create line under recipient's name
Dim point9 As New Point(245, 240)
Dim point10 As New Point(845, 240)
e.Graphics.DrawLine(blackPen2, point9, point10)
' Create line under company name
Dim point11 As New Point(245, 320)
Dim point12 As New Point(845, 320)
e.Graphics.DrawLine(blackPen2, point11, point12)
' Create line under date
Dim point13 As New Point(117, 605)
Dim point14 As New Point(281, 605)
e.Graphics.DrawLine(blackPen2, point13, point14)
' Create line under instructor name
Dim point15 As New Point(380, 605)
Dim point16 As New Point(580, 605)
e.Graphics.DrawLine(blackPen2, point15, point16)
' Create line under Company name 2
Dim point17 As New Point(580, 605)
Dim point18 As New Point(950, 605)
e.Graphics.DrawLine(blackPen2, point17, point18)
Loop
End If
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PrintDocument1_PrintPage(sender, e)
End If
End Sub