Printing Utilities Special Topics |
PocketHTMLprint_NetCF
SDK 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 |
|
Brother PocketJet 3 and PocketJet 200 |
|
Pentax PocketJet 3 Plus and PocketJet
II |
|
Pentax PocketJet 6 |
BROTHER_PJ6plus |
Pentax PocketJet 6 Plus |
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 |
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 |
INTERMECPB |
Intermec PB3/PB2 (Note: For PB42, PB50, use INTERMEC) |
IPC_PP50 |
IPC PP-50 |
IPC_PP55 |
IPC PP-55 |
|
OMNIPrint 6240 and 6400 |
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 & 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 |
COM0 | Com0: serial port |
TOFILE |
Print to file "\OUTPUT.PRN" |
LPT |
LPT: parallel port |
|
|
Baudrate - One of the following PORT_SPEED values. Defaults to USE_CURRENT.
Description |
|
USE_CURRENT |
Use most recently saved baud rate from registry. |
S_4800 |
4800 baud |
S_9600 |
9600 baud |
S_19200 |
19200 baud |
S_38400 |
38400 baud |
S_57600 |
57600 baud |
S_115200 |
115200 baud |
OpenPort - If true, tries to immediately establish communication with the selected printer and port. If false, delays until ready to send print data.
This method selects paper settings (see also SetupPaperCustom).
Syntax:
(2 overloaded versions):
void
SetupPaper(PAPER_SELECTION PaperSize,ORIENTATION Orientation);
void SetupPaper(PAPER_SELECTION
PaperSize,ORIENTATION Orientation,
double LeftMargin,double
TopMargin,double RightMargin,double
BottomMargin);
PaperSize - One of the following PAPER_SELECTION values:
Description |
|
USE_CURRENT |
Use most recently saved paper selection from registry. |
LETTER |
Letter sized paper |
A4 |
A4 paper |
B5 |
B5 paper |
LEGAL |
Legal-sized paper |
CUSTOM |
Custom-sized paper (see SetupPaperCustom as preferred way to set CUSTOM paper). |
Orientation - One of ORIENTATION values:
Description |
|
USE_CURRENT |
Use most recently saved orientation selection from registry. |
PORTRAIT |
Portrait mode |
LANDSCAPE |
Landscape (sideways) mode |
LeftMargin, TopMargin, RightMargin, BottomMargin: Sets printing margins in ScaleMode units. Defaults to most recently saved margin values. To leave any margin values unchanged, use -1.0 for margin setting.
This method selects CUSTOM paper type and sets paper size.
Syntax:
(2 overloaded versions):
public
void SetupPaperCustom(ORIENTATION
Orientation,
double CustomPaperWidth,double
CustomPaperHeight);
public void
SetupPaperCustom(ORIENTATION Orientation,
double CustomPaperWidth,double
CustomPaperHeight,double
LeftMargin,
double TopMargin,double
RightMargin,double BottomMargin);
Orientation: See ORIENTATION
table.
CustomPaperWidth,
CustomPaperHeight - Paper width and height (in ScaleMode units)
LeftMargin, TopMargin, RightMargin, BottomMargin - Margins used for
printed page (in ScaleMode units)
This method programmatically sets a variety of "other" printing
options
Syntax:
void
SetupPrinterOther(FORMFEED_SETTING FFSetting,double
FormFeedScrollDistance,
DENSITY Density,SERIAL_HANDSHAKE Handshake,BITFLAG BitFlags,
COMPRESSION Compression,DITHER
Dither,PRINTQUALITY PrintQuality);
FFSetting- One of the following FormFeed selections:
Description |
|
USE_CURRENT |
Use most recently saved setting from registry. |
NORMAL |
Printer sends formfeed command to printer at end of each
page. |
PAPERHEIGHT |
PrinterCE scrolls printer to selected paper height. |
SCROLL |
PrinterCE will scroll paper by "FormFeedScrollDistance"
distance from last printed portion of page. |
FormFeedScrollDistance - Distance (in ScaleMode units) to scroll if
FFSetting=FFEED_SCROLL
Density - Darkness/Lightness setting for print density.
Description |
|
USE_CURRENT |
Use most recently saved setting from registry. |
EXTRALIGHT |
Lightest printing |
EXTRALIGHT |
Lightest printing |
LIGHTER |
Medium light printing |
NORMAL |
Normal printing density |
DARKER |
Darker printing |
EXTRADARK |
Darkest printing |
Handshake - Valid only for serial port selections (COMx) - Defines serial port handshake:
Description |
|
USE_CURRENT |
Use most recently saved setting from registry. |
SOFTWARE |
Uses Xon/Xoff |
HARDWARE |
Uses hardware control lines |
NO_HANDSHAKE |
No handshaking of serial port. |
BitFlags - Miscellaneous bit settings (OR these together):
BITFLAG Enumeration | Description |
USE_CURRENT |
Use most recently saved setting from registry. |
ADJUST_IR |
Forces IR (infrared) buffer size to 2040 bytes for Canon BJC printers and to 64 bytes for all other printers... this fixes IR hardware incompatibilities in a few printers. |
ALTERNATE_IR |
(Obsolete) There are a few Windows CE devices that have trouble printing through the infrared port to specific printers due to problems in the infrared port driver of the device. This option provides an alternate (generally less robust) approach to IR connection. |
COLOR |
Enables color printing for HP PCL, Canon BJC, Epson and other color printers. |
CMYONLY |
CMY 3-Color Printing - for color printers that do not have black ink. |
SINGLETHREAD |
PrinterCE normally uses two threads (separate processes) for printing. Selecting BITFLAG_SINGLETHREAD forces PrinterCE to use one thread. |
Compression - Select data compression mode for printing:
Description |
|
USE_CURRENT |
Use most recently saved setting from registry. |
STANDARD |
Uses standard printer compression for faster printing (default) |
NONE |
No compression - much slower printing. |
Dither - Select Dither or Diffusion technique for image conversion :
Description |
|
USE_CURRENT |
Use most recently saved setting from registry. |
DIFFUSION |
Uses color diffusion (default) |
DITHER |
Use dithering |
PrintQuality - Select High Quality vs Draft mode printing (if available). Note: DraftMode is not
supported for many printer types and may not result in
any difference.