Page 1
IrDA printing within eVB or VB.NET
Now you can print right from within
your eVB or VB.NET application using the IrDA port. Sapphire
Solutions Ltd have developed an easy-to-use utility
that can communicate with an IrDA printer using the Infra-red
port on your Pocket PC device.
Overview
You can download the demo
project of the Sapphire IrDA DLL which
includes a personal use version of the utility. This utility
allows an application to connect to a remote IrDA printer
and send data to be printed. It also allows you to enter
escape sequences to allow for advanced functionality depending
on your printer's specification.
Running the Project
After downloading and unzipping the
SapphireIrDA demo project, you need to add the appropriate
version of the SapphireIrDA.DLL to the
\Windows directory on your Pocket PC. If
you are using VB.NET, you will need to include the SapphireIrDA.DLL
into the application directory of your program instead.
You can find the correct DLL in the unzipped project directory
under the appropriate sub-directory. Once you have done
this you can run the desired project file on the client
device.

This demo project shows how to print
a simple string of text to your printer. It also demonstrates
how to use escape sequences that allow you to perform printer
functions such as form feed, double width text, underline
text and bold text. If you want to find out more escape
sequences then it is recommended that you refer to your
printer's specification and try it out with the demo utility.
The Code
To implement IrDA printing in your own
eVB or VB.NET application you only need to create a few
simple calls to the DLL.
Example: Linking the DLL using VB.NET
<DllImport("SapphireIRDA.dll")>
_
Public Function prnConnect(
_
ByVal lLicence
As Integer) As
Integer
End Function
<DllImport("SapphireIRDA.dll")>
_
Public Function prnClosePrinter()
As Integer
End Function
<DllImport("SapphireIRDA.dll")>
_
Public Function prnPrintLine(
_
ByVal sData As
String) As Integer
End Function
Example: Linking the DLL using eVB
Declare Function
prnConnect _
Lib "SapphireIRDA.dll"
( _
ByVal lLicence
As Long) As
Integer
Declare Function prnClosePrinter
_
Lib "SapphireIRDA.dll"
() As Integer
Declare Function prnPrintLine
_
Lib "SapphireIRDA.dll"
(_
ByVal sData As
String) As Integer
A simple example on how to print a string
is shown below:
If (prnConnect(1234567890)
= 0) Then
prnPrintLine("Test print using the SapphireIRDA
DLL")
prnClosePrinter()
End If
Please refer to the demo
project for a more complete example on how to use the
utility including error capturing.
Where to find the demo
The product information page for the
latest Sapphire IrDA utility allows you to download the
personal use version that includes the sample eVB and VB.NET
projects with the demo version of the DLL for each target
platform. This can be found at www.sapphire-solutions.co.uk/product.asp?product=IRDA.
Licence of use
For those that wish to simply experiment
with the utility or use it for personal projects, you can
use the utility absolutely free of charge.
For those that wish to include the utility
into their own commercial applications, they can purchase
a royalty-free licence for the utility online at http://www.sapphire-solutions.co.uk.
This is a one off payment that allows you to distribute
it in any projects created under the registered company.
Please refer to the web site for the latest prices.
Other utilities you may find useful
Sapphire Solutions Ltd have a variety
of other utilities that you may find useful or vital to
your application. Some of these are:
- Sapphire
RAS - Dial up a remote connection and manage phone
book.
- Sapphire
FTP - Communicate with a FTP server (includes directory
navigation).
- Sapphire
GZip - Compress and decompress files into .gz or .zip
format.
- Sapphire
Encrypt - Encrypt or decrypt strings or files ensuring
its confidentiality.
- Sapphire
Buttons - Take control of other buttons on your device.
Please check www.sapphire-solutions.co.uk
for a full listing of available products.