|
Examples
|
|
| 'Declare and create an object instance of Raw Data Printer
|
| '(alternatively, you can use the CreateObject method to create an object instance)
|
| Dim RDP As New RawDataPrinter.Printer
|
|
|
| 'Print some raw data string
|
| RetVal = RDP.PrintRawData "This raw data is printed by Raw Data Printer!"
|
|
|
| 'Send an escape command (set bold printing) with some raw data string (ESC E + text)
|
| RetVal = RDP.PrintRawData Chr(27) & "E" & "This raw data is printed by Raw Data Printer!"
|
|
|
| 'Clean up
|
| Set RDP = Nothing
|
|
|
| 'Declare and create an object instance of Raw Data Printer
|
| Dim RDP As New RawDataPrinter.Printer
|
|
|
| 'Print some raw data string to a specific printer and send a FormFeed to eject the paper
|
| 'Note that the printer name must be specified exactly as it is returned by the GetPrinters method,
|
| 'which actually is the same name that appears in the Windows Control Panel (Printers and Faxes)
|
| RetVal = RDP.PrintRawData "This raw data is printed by Raw Data Printer!", , "EPSON Stylus Photo R200 Series", , True
|
|
|
| 'Clean up
|
| Set RDP = Nothing
|
|
|
|
|
|
|
| 'Declare and create an object instance of Raw Data Printer
|
| Dim RDP As New RawDataPrinter.Printer
|
|
|
| 'Print the contents of a text file (as raw data) and send a FormFeed to eject the paper
|
| RetVal = RDP.PrintRawData , "C:\MyFile.txt", , , True
|
|
|
| 'Clean up
|
| Set RDP = Nothing
|
|
|
| 'Declare and create an object instance of Raw Data Printer
|
| Dim RDP As New RawDataPrinter.Printer
|
|
|
| 'Print data supplied from code in the Data argument and then print the contents of a text file (as raw data)
|
| RetVal = RDP.PrintRawData "This data is supplied from code in the Data argument!" & vbCrLf & vbCrLf, "C:\MyFile.txt"
|
|
|
| 'Clean up
|
| Set RDP = Nothing
|
|
|
| 'Create the Raw Data Printer object
|
| Set RDP = Server.CreateObject("RawDataPrinter.Printer")
|
|
|
| 'Get data from the appropriate HTML form fields
|
| CustomerName = Request.Form("CustomerName")
|
| CustomerAddress = Request.Form("CustomerAddress")
|
| CustomerPhone = Request.Form("CustomerPhone")
|
| ItemNumber = Request.Form("ItemNumber")
|
| ItemDescription = Request.Form("ItemDescription")
|
| UnitPrice = Request.Form("UnitPrice")
|
| Qty = Request.Form("Qty")
|
| TotalPrice = Request.Form("TotalPrice")
|
|
|
|
|
| 'Compose the raw data string from the appropriate HTML fields
|
| OrderData = CustomerName & vbCrLf & CustomerAddress & vbCrLf & CustomerPhone & vbCrLf & ItemNumber & vbCrLf & ItemDescription & vbCrLf & UnitPrice & vbCrLf & Qty & vbCrLf & TotalPrice
|
|
|
| 'Send data to a network printer and issue a FormFeed to eject the page
|
| 'Note, the printer name should be exactly as returned by the GetPrinters method
|
| RetVal = RDP.PrintRawData OrderData, , "\\ServreName\Network Printer Name Here", , True, , , ErrorNumber, ErrorDescription
|
|
|
| 'Clean up
|
| Set RDP = Nothing
|
|
|
| 'Notify the user for print completion (or any errors)
|
| 'RetVal is True if printing was successful, False if an error occurs
|
| If RetVal = True Then
|
| Response.Write "Your order was printing successfully on the server!"
|
| Else
|
| Response.Write "Order print error!" & <br> & "Error Number= " & ErrorNumber & <br> & "Error Description= " & ErrorDescription
|
| End If
|
|
|
| 'Create the Raw Data Printer object
|
| Set RDP = CreateObject("RawDataPrinter.Printer")
|
|
|
| 'Get ticket data from the appropriate HTML fields
|
| TicketCode = document.Form1.TicketCode.value
|
| TicketName = document.Form1.TicketName.value
|
| DeparturePort = document.Form1.DeparturePort.value
|
| ArrivalPort = document.Form1.ArrivalPort.value
|
| DepartureDate = document.Form1.DepartureDate.value
|
| ArrivalDate = document.Form1.ArrivalDate.value
|
| Price = document.Form1.Price.value
|
|
|
| 'Compose the raw data string from the appropriate HTML fields
|
| 'Also, because the printing is performed on a pre-printed ticket (form), some spaces should be appended
|
| 'to the data parts, in order to print on the appropriate positions on the ticket
|
| StrToPrint = " " & TicketCode & vbCrLf
|
| StrToPrint = StrToPrint & " " & TicketName & vbCrLf
|
| StrToPrint = StrToPrint & " " & DeparturePort & " " & ArrivalPort & vbCrLf
|
| StrToPrint = StrToPrint & " " & DepartureDate & " " & ArrivalDate & vbCrLf
|
| StrToPrint = StrToPrint & " " & Price
|
|
|
| 'Send the document to the Raw Data Printer object and issue a FormFeed to eject the ticket
|
| 'You can also specify the printer name, to which the document will be sent
|
| RetVal = RDP.PrintRawData StrToPrint, , "EPSON Stylus Photo R200 Series", , True, , , ErrorNumber, ErrorDescription
|
|
|
| 'Clean up
|
| Set RDP = Nothing
|
|
|
| 'Notify the user for print completion (or any errors)
|
| 'RetVal is True if printing was successful, False if an error occurs
|
| If RetVal = True Then
|
| MsgBox "Ticket Printing Completed Successfully!",,"Raw Data Printer"
|
| Else
|
| MsgBox "Print Error!" & vbCrLf & "Error Number=" & ErrorNumber & vbCrLf & "Error Description=" & ErrorDescription,,"Raw Data Printer"
|
| End If
|
|
|
| 'Create the Raw Data Printer object
|
| Set RDP = CreateObject("RawDataPrinter.Printer")
|
|
|
| 'Query all physical printer devices attached to the system
|
| 'This will also retrieve any logical printers (such as FAX printer driver, PDF printer driver, etc.)
|
| 'The method returns a variant array (string) containing the names of the printers found
|
| Printers = RDP.GetPrinters(PrintersCount)
|
|
|
| P = PrintersCount & " printers were detected on your system:" & vbcrlf & vbcrlf
|
|
|
| For i=0 To UBound(Printers)
|
| P = P & Printers(i) & vbcrlf
|
| Next
|
|
|
| 'Clean up
|
| Set RDP = Nothing
|
|
|
| 'Show the names of detected printers
|
| MsgBox P,,"Raw Data Printer"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|