By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,968 Members | 1,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,968 IT Pros & Developers. It's quick & easy.

how to add multiple pages in print

P: 1
hello sir,

please help me ,how to add multiple pages in print.i have sent my coding also
pls help me....................




Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
  2.         Try
  3.             Dim first, second, third, boundary, head, content, content1, content2, content3, contboun, bottom As String
  4.             Dim i, y As Integer
  5.             Dim font As New Font("Arial", 16, FontStyle.Bold)
  6.             Dim font1 As New Font("Arial", 14)
  7.             Dim rowcount As Integer = 2
  8.             ' If (Directory.Exists("print\print")) Then
  9.             ' Dim filename As String = "print\print"
  10.             ' Dim myfilestream As New System.IO.FileStream(filename, FileMode.Open, FileAccess.ReadWrite)
  11.             ' Dim temp As New System.IO.StreamReader(myfilestream)
  12.             ' no = CInt(temp.ReadLine())
  13.             ' temp.Close()
  14.             ' myfilestream.Close()
  15.             ' End If
  16.             'Dim pageWidth As Integer
  17.             'With PrintDocument1.DefaultPageSettings
  18.             '    pageWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
  19.             'End With
  20.             first = "TAMILNADU STATE TRANSPORT CORPORATION LTD.,TIRUNELVELI."
  21.             e.Graphics.DrawString(first, font, Brushes.Black, 250, 100)
  22.             second = "ISSUE DETAILS"
  23.             e.Graphics.DrawString(second, font, Brushes.Black, 500, 140)
  24.             third = "Vehicle No/Unit No :  " + ListView1.Items(0).SubItems(0).Text + "               Date :" + received + "                                    No:   " + no.ToString
  25.             e.Graphics.DrawString(third, font, Brushes.Black, 100, 180)
  26.             boundary = "==================================="
  27.             contboun = "----------------------------------------------"
  28.             bottom = "     Prepared By                                                                                          Workshop In_Charge                 "
  29.             e.Graphics.DrawString(boundary, font, Brushes.Black, 100, 220)
  30.             head = "Item Code                                    Item_Name                                      Qty                          Value"
  31.             e.Graphics.DrawString(head, font, Brushes.Black, 100, 260)
  32.             e.Graphics.DrawString(boundary, font, Brushes.Black, 100, 300)
  33.             content = ""
  34.             y = 330
  35.             For i = 0 To ListView1.Items.Count - 1
  36.                 content = ListView1.Items(i).SubItems(1).Text + "          "
  37.                 content1 = ListView1.Items(i).SubItems(5).Text + "          "
  38.                 content2 = ListView1.Items(i).SubItems(3).Text + "          "
  39.                 content3 = ListView1.Items(i).SubItems(6).Text + "          "
  40.                 e.Graphics.DrawString(content, font1, Brushes.Black, 120, y)
  41.                 e.Graphics.DrawString(content1, font1, Brushes.Black, 280, y)
  42.                 e.Graphics.DrawString(content2, font1, Brushes.Black, 820, y)
  43.                 e.Graphics.DrawString(content3, font1, Brushes.Black, 1020, y)
  44.                 e.Graphics.DrawString(contboun, font1, Brushes.Black, 100, y + 20)
  45.                 content = ""
  46.                 y += 60
  47.                 rowcount += 2
  48.                 If rowcount > 25 Then
  49.                     e.HasMorePages = True
  50.                     rowcount = 2
  51.                 Else
  52.                     e.HasMorePages = False
  53.                 End If
  54.             Next
  55.         Catch ex As Exception
  56.             MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
  57.         End Try
  58.     End Sub
May 18 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.