|
Printing Utilities Special Topics |
PocketHTMLprint_NetCF
SDK v1.2.5.5 PocketHTMLprint_NetCF SDK provides a set of HTML printing-related functions that allows .NetCF developers using C# and VB.Net to easily add fully formatted printing of HTML files to Windows Mobile Pocket PC and CE.Net ARM/XScale apps. Note: For eVC (C/C++/MFC) apps: PocketHTMLprint SDK
PocketHTMLprint_NetCF SDK
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
STATUS Enumeration |
Description |
|
errNoError |
No error |
|
errUserCancel |
User
cancelled print job |
|
errAbortOperation |
Error
aborted the last print operation (but the print job is still
viable). |
|
errAbortPrint |
Error
aborted the print job |
GetVersion - Property Returns current version number of PocketHTMLprint
Syntax:
int
vsn = hpr.GetVersion;
Returns:
Integer
representation of version number = (Major * 1000) + Minor.
For example: version 1.3 would return value of 1300.
PrintJob
- Prints
the current job and leaves the instance of PocketHTMLprint ready to
receive another HTML print job. To close the instance of HTMLpr after
the print job, use HTMLpr_Close() instead).
Syntax:
bool
PrintJob(bool
KeepPrinterConnection);
Parameter:
KeepPrinterConnection
- If
true,
keeps the current printer connection open after canceling the print job. If
false,
closes the printer connection.
Returns:
true if successful,
false otherwise. Check ErrVal property for
more info on error (see below)
SendFile
-
Print
HTML file - can either be local file or Internet-based URL to HTML web
page that will be downloaded and printed.
Syntax:
bool SendFile(string
pfilename);
Parameter:
pfilename
-
Filename (with path if local file, or full URL if remote web page). For
example, local file might look like:
"file://\\My%20Documents\\HTML\\testing1.htm"
while a remote URL might look like:
"http://www.fieldsoftware.com/PrintPocketCE.htm"
Returns: true if successful, false otherwise. Check ErrVal property for more info on error (see below)
SendStr - Adds HTML string to current print job. This method can be called multiple times to send strings of HTML code until the HTML page has been fully sent. Close() must be called to print the final HTML page.
bool
bool
Parameters:
pstr
- HTML text string
scnt - count of
characters to print in string (if omitted or <= 0, entire string will
be used
Returns:
true if successful,
false otherwise. Check ErrVal property for
more info on error (see below)
SetupAll - Do initial setup and prep, including optionally allowing user to select HTML printing options and printer settings.
Syntax:
bool
SetupAll(USER_SELECT
whichoptions);
Parameter:
whichoptions
- Selects which optional user settings will be used:
|
USER_SELECT Enumeration |
Description |
| ALL_OPTIONS |
Show both HTML print options and Select Printer options dialogs |
|
HTML_PRINT_OPTIONS |
Display HTML print options dialog only |
| SELECT_PRINTER_OPTIONS |
Display Select Printer dialog only |
| NO_OPTIONS |
Skip both HTML printing options and Select Printer options dialogs |
Note that if user presses "Quick Print" on "HTML printing options" dialog, the Printer Selection dialog will be skipped, even if HTML_AllOptions is used.
Returns: true if successful, false otherwise. Check ErrVal property for more info on error (see below).
Notes:
#1: HTML print options can
be programmatically set using SetupHTMLOptions.
#2: Select Printer options can be programmatically set
- see "Programmatically
Selecting Printer and Paper Types" section below.
SetupHTMLOptions - Programmatically set HTML print options (allows skipping HTML Options dialog).
Syntax:
void SetupHTMLOptions(PRINTSIZE
sizing,int CustomSize,PAGERANGE range,int PgFrom,
int PgTo,int Copies,bool PrintHeader,bool ReduceTextSize)
Parameters:
sizing
- Select one of 3 size options:
|
PRINTSIZE Enumeration |
Description |
|
NORMAL |
Print HTML page as defined |
|
SHRINKTOFIT |
Shrink HTML width to fit in current page |
|
CUSTOM |
Shrink/enlarge HTML page "CustomSize" percentage |
CustomSize - If "PrintSizing" is set to PRINTSIZE_CUSTOM, CustomSize is percentage to shrink/enlarge the printed HTML page. Valid range is 25% to 250%.
range - Select one of two page range options:
|
PAGERANGE
Enumeration |
Description |
|
ALL |
Print all pages |
|
PAGES |
Print pages from "PgFrom" to "PgTo" |
PgFrom - starting page to print if PrintRange set to PAGERANGE_PAGES
PgTo - last page to print if PrintRange set to PAGERANGE_PAGES
Copies - Number of copies of HTML document to print
PrintHeader - If true, prints header containing HTML page title and page number, plus footer containing URL address and date/time of print job.
ReduceTextSize - If true reduces all text sizes by about 1/4
![]()
Programmatically Selecting Printer and Paper Types
Most programs that use PocketHTMLprint will want to allow the user to select the printer, connection type (ie. Infrared, Bluetooth, network, serial) as well as paper type. However, some applications need to programmatically set the printer and paper settings in order to restrict users to one specific printer, connection and paper combination. The methods detailed below can be used to set printer and paper values programmatically.
Here is an example of code that programmatically sets HTML print options and printer settings. SetScaleMode() is used to set scale mode of measurement values for SetupPaper to inches, centimeters, etc (see ScaleMode method in PrinterCE SDK documentation).
//Set
HTML
print options and Printer settings
hpr.SetupHTMLOptions(PRINTSIZE_SHRINKTOFIT,0,PAGERANGE_ALL,0,0,1,true,true);
hpr.SetupNetPath(@"\\FieldSoft\HP995c");
hpr.SetupPrinter(PR_HP_PCL, PORT_NETPATH, S_DONTCARE);
hpr.SetScaleMode(HTMLpr.MEASUREMENT_UNITS.INCHES);
hpr.SetupPaper(vbLetter, vbPortrait, 0, 0, 0.5, 0.5, 0.5, 0.5);
hpr.SetupPrinterOther(FFEED_NORMAL,1.0,DENSITY_NORMAL,SOFTWARE_HANDSHAKE,BITFLAG_COLOR,
COMPRESSED_ON,DITHER_ON,DRAFTMODE_OFF);
//Now, setup HTMLpr but do not pop up HTML options or Select Printer dialog
hpr.SetupAll(NO_OPTIONS);
Set IP address and port for networked print server. SetupNetIPPrinter must be called before calling SetupPrinter().
Syntax: void SetupNetIPPrinter(string netstr,int port,bool OpenPort);
Parameters
netstr
- IP
address string
port - IP port value
OpenPort - true if want to establish communication link immediately
Example: prce.SetupNetIPPrinter("192.168.0.234",9101,false);
Set IP address and port for networked print server. SetupNetIPPrinter must be called before calling SetupPrinter(). SetupNetSharedPrinter must be called before calling SetupPrinter().
Syntax: void SetupNetSharedPrinter(string netstr,bool OpenPort);
Parameters
netstr
- Network
path string to shared printer.
OpenPort - true if want to establish communication link immediately
Example:
prce.SetupNetSharedPrinter("\\\\FieldSoft\\HP995c",true);
This establishes connection to printer "HP995c" on networked PC
"FieldSoft".
Programmatically
set the printer and port settings
Syntax:
2 overloaded versions
void
SetupPrinter(PRINTER Printer,PORT Port,bool
OpenPort);
void SetupPrinter(PRINTER Printer,PORT Port,PORT_SPEED Baudrate,bool OpenPort);
Printer - One of the following PRINTER selections:
|
Description |
|
|
USE_CURRENT |
Use most recently saved printer from registry. |
| ABLE_AP1300 | Able Systems Ap1300 |
| AXIOHM_A631 | Axiohm A631 |
| BROTHER | Brother MPrint |
|
CANONBJ360 |
Canon BubbleJet compatible printers |
| CANONBJ600 | Canon PIXMA iP90, i80, i70 |
| CANONBJ300 | Canon BubbleJet 300 dpi |
|
CITIZEN_203 |
Citizen 203DPI printers |
|
CITIZEN_CMP10 |
Citizen CMP-10 |
|
CITIZEN_PD22 |
Citizen PD-22 |
|
CITIZEN_PD04 |
Citizen PD-04, PD-24 |
|
CITIZEN_PN60 |
Citizen PN60i |
|
ELTRADE |
Eltrade Mobilife |
|
EPSON_ESCP2 |
Epson ESC/P 2 compatible printers |
|
EPSON_STYLUS |
Epson Stylus compatible printers |
|
EPSON_TM_P60 |
Epson TM-P60 |
|
EXTECH_2 |
Extech 2" Thermal |
|
EXTECH_3 |
Extech 3" Thermal |
|
EXTECH_4 |
Extech 4" Thermal |
|
FUJITSU_FTP628 |
Fujitsu FTP-628WSL110 |
|
GEBE_FLASH |
GeBE Flash 4" Thermal |
|
GENERIC24_180 |
Generic Epson compatible 180DPI 24-pin printers (LQ/ESC) |
|
GENERIC24_360 |
Generic Epson compatible 360DPI 24-pin printers (LQ/ESC) |
|
GENERIC24_203 |
Generic Epson compatible 203DPI 24-pin printers (LQ/ESC) |
|
HP_PCL |
HP PCL compatible - includes DeskJet and LaserJet |
|
INTERMEC |
Intermec PB/PW/68/78 Thermal |
|
IPC_PP50 |
IPC PP-50 |
|
IPC_PP55 |
IPC PP-55 |
|
|
OMNIPrint 6240 and 6400 |
|
ONEIL |
O'Neil MicroFlash |
|
PANASONIC_JTH200PR |
Panasonic JTH200PR |
|
PENTAX_200 |
Pentax PocketJet 3 and PocketJet 200 |
|
PENTAX_300 |
Pentax PocketJet 3 Plus and PocketJet
II |
|
PENTAX_RUGGEDJET |
Pentax RuggedJet 3 and RuggedJet 4 |
|
PERIPHERON_NOMAD |
Peripheron Nomad |
|
POCKET_SPECTRUM |
Pocket Spectrum |
|
S_PRINT |
CUSTOM s'print |
|
SATO |
SATO MB200i |
|
SEIKO3445 |
Seiko DPU-3445 |
|
SEIKO_L465 |
Seiko DPU-L465 |
|
TALLY_MIP360 |
TallyGenicom MIP360 rugged 24-pin dot matrix printer |
|
TALLY_MTP4 |
|
| ZEBRA | Zebra Cameo, Encore and QL |
|
SIPIX |
SiPix A6 printer |
|
DYMOCOSTAR |
DymoCoStar label printers |
|
SEIKOLABELWRITER |
Seiko LabelWriter printers |
Port - One of the following PORT selections:
|
Description |
|
|
USE_CURRENT |
Use most recently saved port from registry. |
|
INFRARED |
Infrared port |
|
NETPATH |
Print to shared printer on a networked host PC |
|
NETIP |
Print to network IP printer - a printer with its own IP address |
|
COMPAQ_BT |
HP/Compaq Bluetooth iPAQ or sleeve |
|
IPAQ_BT |
HP/Compaq Bluetooth iPAQ or sleeve |
|
SOCKETCOM_BT |
Socket Bluetooth card support |
| WIDCOMM_BT | |
|
COM1 |
Com1: serial port |
|
COM2 |
Com2: serial port |
|
COM3 |
Com3: serial port |
|
COM4 |
Com4: serial port |
|
COM5 |
Com5: serial port |
|
COM6 |
Com6: serial port |
|
COM7 |
Com7: serial port |
|
COM8 |
Com8: serial port |
| COM9 | Com9: serial port |
|
TOFILE |
Print to file "\OUTPUT.PRN" |
|
LPT |
LPT: parallel port |
|
|
|