hello sir,
please help me ,how to add multiple pages in print.i have sent my coding also
pls help me............. .......
please help me ,how to add multiple pages in print.i have sent my coding also
pls help me............. .......
Code:
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Try
Dim first, second, third, boundary, head, content, content1, content2, content3, contboun, bottom As String
Dim i, y As Integer
Dim font As New Font("Arial", 16, FontStyle.Bold)
Dim font1 As New Font("Arial", 14)
Dim rowcount As Integer = 2
' If (Directory.Exists("print\print")) Then
' Dim filename As String = "print\print"
' Dim myfilestream As New System.IO.FileStream(filename, FileMode.Open, FileAccess.ReadWrite)
' Dim temp As New System.IO.StreamReader(myfilestream)
' no = CInt(temp.ReadLine())
' temp.Close()
' myfilestream.Close()
' End If
'Dim pageWidth As Integer
'With PrintDocument1.DefaultPageSettings
' pageWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
'End With
first = "TAMILNADU STATE TRANSPORT CORPORATION LTD.,TIRUNELVELI."
e.Graphics.DrawString(first, font, Brushes.Black, 250, 100)
second = "ISSUE DETAILS"
e.Graphics.DrawString(second, font, Brushes.Black, 500, 140)
third = "Vehicle No/Unit No : " + ListView1.Items(0).SubItems(0).Text + " Date :" + received + " No: " + no.ToString
e.Graphics.DrawString(third, font, Brushes.Black, 100, 180)
boundary = "==================================="
contboun = "----------------------------------------------"
bottom = " Prepared By Workshop In_Charge "
e.Graphics.DrawString(boundary, font, Brushes.Black, 100, 220)
head = "Item Code Item_Name Qty Value"
e.Graphics.DrawString(head, font, Brushes.Black, 100, 260)
e.Graphics.DrawString(boundary, font, Brushes.Black, 100, 300)
content = ""
y = 330
For i = 0 To ListView1.Items.Count - 1
content = ListView1.Items(i).SubItems(1).Text + " "
content1 = ListView1.Items(i).SubItems(5).Text + " "
content2 = ListView1.Items(i).SubItems(3).Text + " "
content3 = ListView1.Items(i).SubItems(6).Text + " "
e.Graphics.DrawString(content, font1, Brushes.Black, 120, y)
e.Graphics.DrawString(content1, font1, Brushes.Black, 280, y)
e.Graphics.DrawString(content2, font1, Brushes.Black, 820, y)
e.Graphics.DrawString(content3, font1, Brushes.Black, 1020, y)
e.Graphics.DrawString(contboun, font1, Brushes.Black, 100, y + 20)
content = ""
y += 60
rowcount += 2
If rowcount > 25 Then
e.HasMorePages = True
rowcount = 2
Else
e.HasMorePages = False
End If
Next
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
End Try
End Sub