Home

Printing Utilities
  PrintPocketCE
  PIEprint
  PocketPixPrint
  PocketShot
 
PocketClipPrint
   + + + + +

Software Developers
  PrinterCE SDK
 
PrinterCE.NetCF SDK
  PocketHTMLprint SDK

Special Topics
  Supported Printers
  Bluetooth Printing
  Network Printing

Arcade Games
  SockOut
  MazeCraze

Contact Info

PocketHTMLprint SDK

For Software Developers - Add fully formatted
HTML printing to your eVC (C/C++/MFC) apps.
Version 1.270 Available  See What's New

Library Name : PocketHTMLprint.lib
DLL Name : PocketHTMLprint.dll

PocketHTMLprint SDK provides a set of HTML printing-related functions that allows eVC (C/C++/MFC) developers to easily add fully formatted printing of HTML files to apps running on Pocket PC and CE.Net ARM/XScale devices.

NEW: Print HTML files using VS.Net C# and VB.Net:
Click to see PocketHTMLprint_NetCF SDK

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:

bullet

PocketHTMLprint.dll - Copy to \Windows folder of your device. 

bullet

PrintDC.dll - Copy to \Windows folder of your device (used by PocketHTMLprint.dll for basic printing functionality).

bullet

PocketHTMLprint.lib - Add reference to this in your app's eVC Project menu -> Settings -> Link tab -> Object and Library Modules list.

bullet

PocketHTMLprint.h - Add #include to this file in your app - add to any .c or .cpp files that use PocketHTMLprint.

bullet

PrCEUser.h - Add #include to this file in your app only if you are using any of the Setup commands found below in section: "Programmatically Selecting Printer and Paper Types"

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),
p
lease contact sales@fieldsoftware.com
bullet

PocketHTMLprint SDK is for software developers.

bullet

Minimum package available is $149.50 (USD) for up to 10 installations.

bullet

License Keys for PocketHTMLprint SDK and PocketHTMLprint_NetCF SDK are interchangeable - your purchased Developer's License for one will work on the other.

bullet

For quotes on larger volumes, info for purchase orders, or other questions email sales@fieldsoftware.com.

bullet

Read PocketHTMLprint License Agreement

bullet

PocketHTMLprint SDK Limitations:
Does NOT support the following tag categories:
    - Script tags (ie. Java Script)
    - CSS (Cascading Style Sheet)
    - Link, inclusion, style and form tags.

horizontal rule

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

}

horizontal rule

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

horizontal rule

PocketHTMLprint SDK
Commands & Properties

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:

bullet

pstr - HTML text string (plain Ascii text)

bullet

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:

bullet

pfilename - Filename (with path if local file, or full URL if remote web page). For example, local file might look like:
   
_T("file://\\My%20Documents\\HTML\\testing1.htm")
  while a remote URL might look like:
   
_T("http://www.fieldsoftware.com/PrintPocketCE.htm")  

bullet

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:

bullet

pstr - HTML text string (Unicode)

bullet

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:

bullet

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:

bullet

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

bullet

CustomSize - If "PrintSizing" is set to PRINTSIZE_CUSTOM, CustomSize is percentage to shrink/enlarge the printed HTML page. Valid range is 25% to 250%.

bullet

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"

bullet

PgFrom - starting page to print if PrintRange set to PAGERANGE_PAGES

bullet

PgTo - last page to print if PrintRange set to PAGERANGE_PAGES

bullet

Copies - Number of copies of HTML document to print

bullet

PrintHeader - If True (1), prints header containing HTML page title and page number, plus footer containing URL address and date/time of print job. 

bullet

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)

horizontal rule

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

 

horizontal rule

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);