'==============================================
'Printing Current Documents
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage()
Y = PrintDocument1.DefaultPageSettings.Margins.Top + 10 e.Graphics.DrawString("INVOICE", headfont, Brushes.Black, X1 + 250, Y)
e.Graphics.DrawString("Cash/Credit Bill ", titlefont, Brushes.Black, X1, Y + 50)
e.Graphics.DrawString("To : " & txtCustomername.Text, titlefont, Brushes.Black, X1, Y + 80)
e.Graphics.DrawString("Date : " & Format(DTsale.Value, "dd-MM-yyyy"), titlefont, Brushes.Black, X1 + 450, Y + 25)
e.Graphics.DrawString("Bill No : " & txtReference.Text, titlefont, Brushes.Black, X1 + 450, Y + 50)
Y = PrintDocument1.DefaultPageSettings.Margins.Top + 120
With PrintDocument1.DefaultPageSettings
e.Graphics.DrawLine(Pens.Black, .Margins.Left, Y + 20, _ .PaperSize.Width - .Margins.Right, Y + 20)
End With
e.Graphics.DrawString("SNO", titlefont, Brushes.Black, X1, Y) e.Graphics.DrawString("NAME", titlefont, Brushes.Black, X2 - 50, Y)
e.Graphics.DrawString("QTY", titlefont, Brushes.Black, X2 + 220, Y)
e.Graphics.DrawString("RATE", titlefont, Brushes.Black, X2 + 280, Y)
e.Graphics.DrawString("MRP", titlefont, Brushes.Black, X2 + 345, Y)
e.Graphics.DrawString("TOTAL", titlefont, Brushes.Black, X2 + 425, Y)
Y = Y + 30
While itm < ListItems.Items.Count
Dim str As String
'str = ListItems.Items(itm).Text
e.Graphics.DrawString(itm + 1, tableFont, Brushes.Black, X1, Y)
str = ListItems.Items(itm).SubItems(1).Text
Dim R As New RectangleF(X2 - 50, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, R)
str = ListItems.Items(itm).SubItems(4).Text
Dim k As New RectangleF(X2 + 220, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, k)
str = ListItems.Items(itm).SubItems(5).Text
Dim M As New RectangleF(X2 + 235, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, M)
str = Format(ListItems.Items(itm).SubItems(7).Text, "Fixed")
Dim N As New RectangleF(X2 + 280, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, N)
'''''' str = Format(ListItems.Items(itm).SubItems(6).Text, "Fixed")
Dim L As New RectangleF(X2 + 340, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, L)
str = SetSpacing(Format(ListItems.Items(itm).SubItems(8).Text, "Fixed"), 10)
Dim O As New RectangleF(X2 + 400, Y, W2, 80)
e.Graphics.DrawString(str, tableFont, Brushes.Black, O)
Dim lines, Cols As Integer
e.Graphics.MeasureString(str, tableFont, New SizeF(W2, 50), _ New StringFormat(), Cols, lines)
Dim Yc As Integer
Yc = Y
Y = Y + lines * tableFont.Height + 5
Y = Math.Max(Y, Yc)
itm = itm + 1
End While
e.Graphics.DrawString("Net Amount : " & SetSpacing(Format(txtNetAmount.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 15)
e.Graphics.DrawString("Roundof : " & SetSpacing(Format(txtRounof.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 35)
e.Graphics.DrawString("Paid Amount : " & SetSpacing(Format(txtPaymentAmount.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 55)
e.Graphics.DrawString("Balance : " & SetSpacing(Format(txtbalance.Text, "Fixed"), 10), titlefont, Brushes.Black, X2 + 240, Y + 75)
e.Graphics.DrawString("", titlefont, Brushes.White, X2 + 240, Y + 105)
End Sub