PIOS Printer API
Guidelines
This document explains several guidelines for the Peripheral Input/Output Services (PIOS) Printer API of the SAP NetWeaver Developer Studio. Each of the guidelines is discussed below.
These guidelines are intended for all developers working on the SAP NetWeaver Developer Studio in a mobile application with printer peripheral requirements. It helps the developer get the most out of the PIOSinfrastructure. The developer can access these features provided by PIOS through the SAP NetWeaver Mobile client API.
Printer Connection
Since multiple applications can run in a mobile device at a given time, it is recommended that mobile applications open the connection to the printer when they are ready to send data to the printer and close the connection when they have finished. This prevents other applications from waiting for the first one to close before they can open a connection. If a mobile application opens the printer connection when it starts and does not close it until it stops, no other application can use the printer until the first application is stopped. Any other mobile application that tries to open a connection to the printer receives an error message.
DPI Awareness
Dots Per Inch (DPI) is the standard unit of measure used for printer resolution. Different printer models can have different resolutions. A developer must be aware of this while writing an application that works with more than one printer model. If the application prints an image, the size of the printed image can vary depending on the printer resolution. For instance, an image printed with a resolution of 300 DPI can be twice as large as an image printed with a 600 DPI resolution. Developers must write applications that can handle all possible DPIs.
Printer Head Width
Mobile application developers must use printer head width information returned in points to avoid hard-coding this information into mobile applications. Hard coding the information limits the capabilities for running the application on multiple printer models.
Page Size Awareness
If an application is written for a printer that uses the Page measurements attribute (only supported for non-continuous paper printers), it can take advantage of this feature and position the fields to be printed according to the paper size. The term “fields” as used in this paragraph refers to text, lines, images, and barcodes.
Use of Field Metrics
Given the fact that printers vary in size, developers should make use of the field and page metrics to position images, barcodes, and graphics on the printed page.
Image Handling
Since loading images is time consuming, images should be loaded during the application installation cycle. In other words, the loading and deletion of images should not occur continuously throughout the execution of the mobile application.
Font Mapping
The API has virtual fonts that map to physical fonts in the printer. Virtual fonts can be added, removed, or modified. It is important to remember that if a font (virtual) is added in the API, then its counterpart, the physical font, must be added to the printer as well. Also, a new virtual font can be set to be a copy of an existing font with modified attributes. The font name parameter must exist in the printer.
Scalable and Bitmapped Fonts
It is recommended to use scalable fonts over bitmapped fonts whenever possible (not all printers support both font types). Scalable fonts make better use of higher resolutions because they are based on vector graphics and are more easily scaled than bitmapped fonts. Bitmapped fonts can make their pixels evident when their size is enlarged.
Printing Copies
Printing several copies of the same data should be done by providing the desired number of copies to the doPrint() method. There is no need to go through another print cycle, sending the same data for a copy.
Unbuffered Methods
These are methods that are directly sent to the printer. They do not pass through the printer buffer and therefore cannot be canceled. The unbuffered methods are clearError(), getStatus(), and advance().

The advance() method must be used only to position the print head to a specific position on the paper. To move forward in line mode developers should use the printText() method using an empty string.
Raw Bytes
A send raw bytes method exists but its use is not encouraged as it ties applications to specific printer models. The resulting behavior, for other printer models, cannot be predicted.