способ печати с сервера на локальный принтер (термопринтер)
всем привет,
я здесь, потому что не знаю, где я могу найти какое - либо решение моей проблемы. я разработал сборники тарифов на билеты.и это онлайн (интранет-компания).мне удается распечатать билет через термальную систему printer.no вообще проблема.
но проблема заключается в том, что я тестирую веб-страницу на месте пользователя.когда я нажимаю кнопку print, она продолжает работать до бесконечности, что означает, что ничего не происходит.. :( я предполагаю, что сервер не может настроить/достичь принтера, который мы установили локально на месте пользователя.
поэтому я очень надеюсь, что какой-то метод или выход из этой проблемы будет решен.мне действительно нужно, чтобы эта проблема была решена, так как я попросил задержать веб, чтобы быть живым раньше.
вот код, который я использую:
Public Function PreparePrintDocument() As PrintDocument ' Make the PrintDocument object. Dim print_document As New PrintDocument ' Install the PrintPage event handler. AddHandler print_document.PrintPage, AddressOf DrawStringPointF 'Print_PrintPage ' Return the object. Return print_document End Function Public Sub DrawStringPointF(ByVal sender As Object, ByVal e As PrintPageEventArgs) 'Dim vEmplid As String = "000000" 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() 'd("ticketid").ToString() 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") ' Create string to draw. 'Dim drawString As [String] = "Title Ticket" 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 ' Create font and brush. 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) ' Create point for upper-left corner of drawing. 'Dim drawPoint As New PointF(10.0F, 40.0F) 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) ' Draw string to screen. e.Graphics.DrawImage(bitmap, 10, 15, 12.0F * width, 0.08F * height) 'e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint) 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 ' Make a PrintDocument object. Dim print_document As PrintDocument 'For x = 1 To 1 print_document = PreparePrintDocument() ' Print immediately. print_document.Print() 'Next 'ReadFile() 'printDocument1.Print() End Sub
если есть другие способы пожалуйста скажите мне
заранее спасибо,
мусив.