hi all,
im here because i dont know where i can find any solution for my problem. i developed ticket fare collections.and it is online (intranet company).i manage to print the ticket through thermal printer.no problem at all.
but come the problem is when i test the web page at user's place.when i click button print it is keep run til infinity.means nothing happen.. :( i assume the server cannot configure/reach the printer which we installed locally at the user's place.
so i really hope any method or way out from this problem.i really need this problem to be solve since i asked for delay the web to be live before.
here the code im using:
Public Function PreparePrintDocument() As PrintDocument
Dim print_document As New PrintDocument
AddHandler print_document.PrintPage, AddressOf DrawStringPointF
Return print_document
End Function
Public Sub DrawStringPointF(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim connection As New SqlConnection(connectionString)
connection.Open()
Dim sqlstr As String = "select distinct a.ticketid,b.station_name as stationid,c.station_name as destination,CONVERT(VARCHAR(12),date_time,103) AS Date, CONVERT(VARCHAR(5),date_time,108) AS Time, " _
& " CONVERT(VARCHAR(5),tarikhrefcan,108) AS Date,d.station_name as ticket_type,e.station_name as journey_type,a.amount,a.refcanby " _
& " from ticketcollections as a,station_tbl as b,station_tbl as c,station_tbl as d,station_tbl as e " _
& " where a.ticketid = '" + TicketId.Text + "' " _
& " and a.refcanby = '" + HttpContext.Current.Session("Emplid") + "' " _
& " And a.stationid = b.staffid " _
& " And b.jenis = 0 " _
& " And a.destination = c.staffid " _
& " And c.jenis = 0 " _
& " And a.ticket_type = d.staffid " _
& " And d.jenis = 4 " _
& " And a.journey_type = e.staffid " _
& " and e.jenis=3 "
Dim c As New SqlCommand(sqlstr, connection)
c.Connection = connection
Dim d As SqlDataReader = c.ExecuteReader()
While d.Read()
TicketId.Text = d.GetString(0)
stationid.Text = d.GetString(1)
Destination.Text = d.GetString(2)
time.Text = d.GetString(4)
dates.Text = d.GetString(3)
tickettype.Text = d.GetString(6)
journeytype.Text = d.GetString(7)
amount.Text = Convert.ToDecimal(d(8))
issuedby.Text = d.GetString(9)
refdate.Text = d.GetString(5)
Today.Date.ToString("dd/MMM/yyyy")
Dim drawString1 As [String] = stationid.Text & " > " & Destination.Text
Dim drawString2 As [String] = Today.Date.ToString("dd/MMM/yyyy")
Dim drawString3 As [String] = tickettype.Text & " " & journeytype.Text & " RM " & amount.Text
Dim drawString4 As [String] = DateTime.Now.ToString("HH:MM")
Dim drawString5 As [String] = TicketId.Text & " " & issuedby.Text
Dim drawString6 As [String] = "Terms & Condition"
Dim drawString7 As [String] = "Not valid as a ticket"
Dim drawString8 As [String] = "Refund Receipt"
Dim bitmap As New System.Drawing.Bitmap("C:\Logo.jpg")
Dim width As Integer = bitmap.Width
Dim height As Integer = bitmap.Height
Dim drawFont As New Font("Arial", 12, FontStyle.Bold)
Dim drawFont2 As New Font("Arial", 6, FontStyle.Bold)
Dim drawFont3 As New Font("Arial", 8, FontStyle.Bold)
Dim drawFont4 As New Font("Arial", 18, FontStyle.Bold)
Dim drawBrush As New SolidBrush(Color.Black)
Dim drawPoint1 As New PointF(10.0F, 83.0F)
Dim drawPoint2 As New PointF(10.0F, 55.0F)
Dim drawPoint3 As New PointF(10.0F, 100.0F)
Dim drawPoint4 As New PointF(10.0F, 120.0F)
Dim drawPoint5 As New PointF(70.0F, 170.0F)
Dim drawPoint6 As New PointF(50.0F, 185.0F)
Dim drawPoint7 As New PointF(90.0F, 155.0F)
Dim drawPoint8 As New PointF(10.0F, 40.0F)
e.Graphics.DrawImage(bitmap, 10, 15, 12.0F * width, 0.08F * height)
e.Graphics.DrawString(drawString1, drawFont, drawBrush, drawPoint1)
e.Graphics.DrawString(drawString2, drawFont4, drawBrush, drawPoint2)
e.Graphics.DrawString(drawString3, drawFont, drawBrush, drawPoint3)
e.Graphics.DrawString(drawString4, drawFont4, drawBrush, drawPoint4)
e.Graphics.DrawString(drawString5, drawFont3, drawBrush, drawPoint5)
e.Graphics.DrawString(drawString6, drawFont2, drawBrush, drawPoint6)
e.Graphics.DrawString(drawString7, drawFont3, drawBrush, drawPoint7)
e.Graphics.DrawString(drawString8, drawFont3, drawBrush, drawPoint8)
End While
End Sub
Protected Sub Print_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Print.Click
If HttpContext.Current.Session("Emplid") = "" Then
Exit Sub
End If
Dim print_document As PrintDocument
print_document = PreparePrintDocument()
print_document.Print()
End Sub
if there are other ways please tell me
thanks in advance,
musiw.