Printing Utilities Special Topics |
For Software
Developers - Add fully formatted Library
Name : PocketHTMLprint.lib
|
Download
Files for PocketHTMLprint SDK Evaluate the full functionality of PocketHTMLprint SDK free for 30-days. Combined file - all 9 below: Download HTMLprint_ALL.zip |
||||||||||
Pocket PC: WM6, WM5 and PPC2003 Pocket PC 2002 CE.Net 5.x: ARMV4/XScale CE.Net 4.x: ARMV4/XScale ARMV4I ARMV4T |
||||||||||
Download and Installation
Instructions:
Download and unzip the files for your device from the download links above. Copy and use the files in the following way:
|
Purchase PocketHTMLprint SDK | ||||||||||||||
To Purchase: Follow "Download and Installation Instructions" below to evaluate PocketHTMLprint SDK free for 30 days. When you purchase at the "Buy Now" link, you will receive a Developer's License Key that is used with the HTMLpr_Register() function (see documentation below) to permanently unlock the evaluation mode for purchased installations. | ||||||||||||||
10 Installations - $149.50 | 25 Installations - $311.25 | 100 Installations - $945.00 | ||||||||||||
If you need
a different number of installations (minimum 10), please contact sales@fieldsoftware.com |
||||||||||||||
|
For C# and VB.Net: See our NEW PocketHTMLprint_NetCF SDK here!
eVC Example: The demo function PrintHTML() below receives an HTML URL path and name (either on the local device or across an Internet connection). The user can select HTML printing options, printer, connection, paper, etc, and then print the HTML page.
//Example 1: Print local HTML file
PrintHTML(_T("file://\\My%20Documents\\HTML\\Invoice345.htm"));
//Example 2: Print HTML file from live Internet connection
PrintHTML(_T("http://www.fieldsoftware.com/PrintPocketCE.htm"));
#include "PocketHTMLprint.h"
//------------------------------------------------------------
// Simple example that uses PocketHTMLprint to print HTML file
//------------------------------------------------------------
void PrintHTML(LPTSTR lphtml)
{
HINSTANCE hLib=LoadLibrary(_T("PocketHTMLprint.dll"));
if (!hLib) //we can't go on... Add error handling and exit
HTMLpr_Startup(GetActiveWindow()); //Initialize pockethtmlprint
//Unlock pockethtmlprint
if (HTMLpr_Register("YOURLICENSEKEY")) { //All is well
//Let user select HTML print options,
// and printer, port, paper type, etc.
if (HTMLpr_SetupAll(HTML_StartOptions)) {
//Ready to print HTML file
HTMLpr_SendFile(lphtml,FALSE);
}
}
//Must call HTMLpr_Close() even if error condition
HTMLpr_Close(); //Done, close HTML printing and free resources
FreeLibrary(hLib); //Done with pockethtmlprint.dll
}
New: Using HTMLpr_PrintJob()
- the new HTMLpr_PrintJob method allows for
printing more than one HTML file or site using one instance of HTMLpr. See
description for HTMLpr_PrintJob() below for full details - here is an
HTMLpr_PrintJob code example:
// If this is first time through, create an instance of HTMLpr
if (hLib==NULL) {
hLib=LoadLibrary(_T("pocketHTMLprint.dll"));
FARPROC lpfnTestInit=NULL;
if (hLib) {
//Make sure we have the version we expect
HTML_PrinterCE_Version = HTMLpr_GetVersion();
if (HTML_PrinterCE_Version<1120) {
//Handle error and exit
}
}
else {
//Unable to create instance of HTMLpr... handle
error and exit
}
//We have our instance, unlock and prep for use
bval=HTMLpr_Register("YOURLICENSEKEY");
HTMLpr_Startup(GetActiveWindow());
}
//Pop up options and select printer dialogs
bval=HTMLpr_SetupAll(HTML_StartOptions | HTML_StartPrinter);
if (HTML_ErrVal!=errNoError) {
//If error or user cancels, close this print job
HTMLpr_CancelJob(false);
//Exit
}
//Ready to print first HTML file
HTMLpr_SendFile(_T("\\My
Documents\\first.html"),FALSE);
HTMLpr_PrintJob(true); //Print job but keep printer connection
open
HTMLpr_SendFile(_T("\\My
Documents\\second.htm"),FALSE);
HTMLpr_PrintJob(false); //Print second job and close printer
connection
HTMLpr_Cancel - Cancels the current print job without printing and frees all resources.
Syntax: void HTMLpr_Cancel();
HTMLpr_CancelJob - Cancels the current print job without printing. Like HTMLpr_PrintJob(), leaves the instance of HTMLpr alive and ready to receive another print job.
Syntax: void HTMLpr_CancelJob(BOOL KeepPrinterConnection);
Parameter: KeepPrinterConnection - If TRUE, keeps the current printer connection open after canceling the print job. If FALSE, closes the printer connection.
HTMLpr_Close - Prints the previously specified HTML page and frees all resources used by PocketHTMLprint. If an error condition has previously been found or set (nHTML_AbortPr != errNoError) no printing will occur, but all resources will be freed. (To leave the instance of HTMLpr ready to receive another HTML print job, use HTMLpr_PrintJob() instead).
Syntax:
BOOL HTMLpr_Close();
Returns:
TRUE if successful, FALSE otherwise. Check
HTML_ErrVal property for
more info on error (see below)
HTMLpr_GetVersion - Returns current version number of PocketHTMLprint
Syntax:
int HTMLpr_GetVersion();
Returns:
Integer
representation of version number = (Major * 1000) + Minor.
Example: version 1.3 would return value of 1300.
HTMLpr_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:
int HTMLpr_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
HTML_ErrVal property for
more info on error (see below)
HTMLpr_Register
- Pass
"Registration Code" to register and unlock PocketHTMLprint for
use by this app. The reg code is received with purchase of PocketHTMLprint.
If NULL or invalid regcode, or if HTMLpr_Register() not
called, PocketHTMLprint will function until 30-day time limit expires.
Syntax:
BOOL HTMLpr_Register(char* regcode);
Parameter:
regcode
- Ascii
text string that is reg code.
Returns: TRUE if successful, FALSE otherwise. Check HTML_ErrVal property for more info on error (see below)
HTMLpr_SendAsciiStr - Adds HTML string to current print task. This method can be called multiple times to send strings of HTML code until the HTML page has been fully sent. HTMLpr_Close() must be called to print the final HTML page.
Syntax:
BOOL HTMLpr_SendAsciiStr(char* pstr,int scnt);
Parameters:
pstr - HTML text string (plain Ascii text) | |
scnt - count of Unicode characters to print in string (if <= 0, entire string will be used |
Returns:
TRUE if successful, FALSE otherwise. Check
HTML_ErrVal property for
more info on error (see below)
HTMLpr_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 HTMLpr_SendFile(LPTSTR pfilename,BOOL UseUnicode);
Parameters:
pfilename
-
Filename (with path if local file, or full URL if remote web page). For
example, local file might look like: | |
UseUnicode - FALSE if file is standard (plain text Ascii) HTML file. TRUE if Unicode file. |
Returns:
TRUE if successful, FALSE otherwise. Check
HTML_ErrVal property for
more info on error (see below)
HTMLpr_SendStr - Adds Unicode HTML string to current print task. This method can be called multiple times to send strings of HTML code until the HTML page has been fully sent. HTMLpr_Close() must be called to print the final HTML page.
Syntax:
BOOL HTMLpr_SendStr(LPTSTR pstr,int scnt);
Parameters:
pstr - HTML text string (Unicode) | |
scnt - count of Unicode characters to print in string (if <= 0, entire string will be used |
Returns: TRUE if successful, FALSE otherwise. Check HTML_ErrVal property for more info on error (see below)
HTMLpr_SetupAll - Do initial setup and prep, including optionally allowing user to select HTML printing options and printer settings.
Syntax:
BOOL HTMLpr_SetupAll(int HTML_Start);
Parameters:
HTML_Start - Selects which optional user settings will be used: |
Constant |
OR Value |
Description |
HTML_StartOptions |
1 |
Display HTML printing options dialog |
HTML_StartPrinter |
2 |
Display Printer Selection dialog. |
To display both
dialogs, OR these:
HTMLpr_SetupAll(HTML_StartOptions | HTML_StartPrinter);
Note that if user presses "Quick Print" on "HTML printing options" dialog, the Printer Selection dialog will be skipped, even if HTML_StartPrinter is used.
To display no dialogs:
HTMLpr_SetupAll(0);
HTML print options can be programmatically set using HTMLpr_SetupHTMLOptions. Also see "Programmatically Selecting Printer and Paper Types" section below.
Returns: TRUE if successful, FALSE otherwise. Check HTML_ErrVal property for more info on error (see below).
HTMLpr_SetupHTMLOptions - Programmatically set HTML print options (allows skipping HTML Options dialog).
Syntax:
void HTMLpr_SetupHTMLOptions(int
PrintSizing, int CustomSize, int PrintRange,
int PgFrom, int PgTo, int Copies, BOOL PrintHeader, BOOL ReduceTextSize);
Parameters:
PrintSizing - Select one of 3 size options: |
Constant |
Value |
Description |
PRINTSIZE_NORMAL |
0 |
Print HTML page as defined |
PRINTSIZE_SHRINKTOFIT |
1 |
Shrink HTML width to fit in current page |
PRINTSIZE_CUSTOM |
2 |
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%. | |
PrintRange - Select one of two range options: |
Constant |
Value |
Description |
PAGERANGE_ALL |
0 |
Print all pages |
PAGERANGE_PAGES |
1 |
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 (1), prints header containing HTML page title and page number, plus footer containing URL address and date/time of print job. | |
ReduceTextSize - If True (1) reduces all text sizes by about 1/4 |
HTMLpr_Startup
-
Performs
startup initialization
Syntax:
BOOL HTMLpr_Startup(HWND hwnd);
Parameter:
hwnd
- Parent
window for Options and Select Printer dialog boxes. If NULL, will use
current ActiveWindow().
Returns:
TRUE if successful, FALSE otherwise. Check
HTML_ErrVal property for
more info on error (see below)
HTML_ErrVal: [Property] - Get or set error conditions:
Constant |
Value |
Description |
errNoError |
0 |
No error |
errUserCancel |
1 |
User
cancelled print job |
errAbortOperation |
2 |
Error
aborted the last print operation (but the print job is still
viable). |
errAbortPrint |
3 |
Error
aborted the print job |
Programmatically Selecting Printer and Paper Types
Most apps 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 projects want to restrict users to one specific printer, connection and paper combo.
For projects that have a designated printer, the following four functions can be used to set printer and paper values programmatically. These functions exactly mirror the equivalent functions found in PrinterCE SDK - so, for example, HTMLpr_SetupPrinter() is identical to PrinterCE's SetupPrinter() and so on.
To use the functions below, download and include in your project the PrinterCE SDK file "PrCEUser.h"- (which contains a number of constant definitions used be the functions below. Download PrCEUser.h here.
For full definition of the functions below, visit PrinterCE SDK documentation here and view PrinterCE's equivalent SetupPrinter(), SetupPaper(), SetupPrinterOther() and SetupNetPath() methods.
BOOL HTMLpr_SetupPrinter(long Printer,long Port,long
Baudrate);
BOOL HTMLpr_SetupPaper(long PaperSize, long Orientation, float PaperWidth,
float PaperHeight, float LeftMgn, float TopMgn, float RightMgn,
float
BottomMgn);
BOOL HTMLpr_SetupPrinterOther(long FFSetting,float FFScroll,
long Density,long Handshake,long BitFlags,long Compressed,
long Dither,long
DraftMode);
BOOL HTMLpr_SetupNetPath(LPTSTR NetString);
void HTMLpr_SetScaleMode(int scalemode);
Below is an example of code that programmatically sets HTML print options
and printer settings. HTMLpr_SetScaleMode() is used to set scale mode of
measurement values for SetupPaper to inches, centimeters, etc (see
ScaleMode method in PrinterCE SDK documentation).
//HTML
print options
HTMLpr_SetupHTMLOptions(PRINTSIZE_SHRINKTOFIT,0,
PAGERANGE_ALL,0,0,1,TRUE,TRUE);
HTMLpr_SetupNetPath(_T("\\\\FieldSoft\\HP995c"));
HTMLpr_SetupPrinter(PR_HP_PCL, PORT_NETPATH, S_DONTCARE);
HTMLpr_SetScaleMode(vbInches);
HTMLpr_SetupPaper(vbLetter, vbPortrait, 0, 0, 0.5, 0.5, 0.5, 0.5);
HTMLpr_SetupPrinterOther(FFEED_NORMAL,1.0,DENSITY_NORMAL,
SOFTWARE_HANDSHAKE,BITFLAG_COLOR,COMPRESSED_ON,DITHER_ON,DRAFTMODE_OFF);
//Now, set
initial settings but do not pop up HTML options dialog
// or Select Printer dialog
HTMLpr_SetupAll(0);