直接通過您的Pocket PC打印將是一件非常有用的事情,特別是當您需要給您的客戶接受收據時。IrDA為您提供了該項功能,您可以通過它直接建立其設備與打印機的連接操作。Sapphire IrDA Utility允許您在您的程序中指定附近的打印機執行打印操作。
Printing from your application can be a very useful tool in a situation where you need to give a receipt to your customer direct from your Pocket PC. The ideal solution is to use an IrDA enabled printer with the IrDA port on your device. The Sapphire IrDA Utility allows you to print to such a printer right within your application.
通過以下功能,Sapphire IrDA Utility可以方便操作紅外打印機:
- 與 IrDA 所支持的打印機建立連接
- 在打印機中打印文本信息
- 在打印機中添加頁面標識線和換頁打印
- 關閉與打印機的連接
實例代碼該操作是如此簡單的,您只需在您的程序中聲明相應的DLL函數,然后在您需要的地方調用即可。以下是一個VB.NET的示范程序,用于演示如何與打印機建立連接和打印文本字符串內容.
Dim iRet As Integer
Dim sLine As String
iRet = prnConnect(SapphireIRDALicence)
If (iRet = 0) Then
' Start printing the text
sLine = "Test print using the SapphireIRDA DLL"
If (prnPrintLine(sLine, sLine.Length)
MsgBox("Failed prnPrintLine")
End If
End If
The Sapphire IrDA Utility makes infra-red printing easy with the following functionality:
- Establish a connection with a IrDA enabled printer
- Print text to the printer
- Print new lines and form feeds to the printer
- Close the connection to the printer
Sample Code
Implementation couldn’t be easier, simply declare the DLL function as a function within your application and call it as though you wrote it yourself. Here’s a sample demo on how to connect to a printer and print a string of text within
VB.NET.
Dim iRet As Integer
Dim sLine As String
iRet = prnConnect(SapphireIRDALicence)
If (iRet = 0) Then
' Start printing the text
sLine = "Test print using the SapphireIRDA DLL"
If (prnPrintLine(sLine, sLine.Length) <> 0) Then
MsgBox("Failed prnPrintLine")
End If
End If