com.sap.ip.me.api.pios.printer
Class LinePrinter

java.lang.Object
  extended bycom.sap.ip.me.api.pios.connection.Connection
      extended bycom.sap.ip.me.api.pios.printer.PrinterConnection
          extended bycom.sap.ip.me.api.pios.printer.LinePrinter

public abstract class LinePrinter
extends PrinterConnection

Use this class to print text, barcodes, and images one line at a time, specifying field alignment. This printer mode is commonly used for continuous paper printers. Every field takes one line. After a field is printed the current line position is advanced. Not all printers support alignment.

Example: Center text in a line
 
 
	Connector connector = Connector.getInstance();
 
	DriverInfo[] printers = connector.listDrivers(ConnectionType.PRINTER);
	PrinterParameters parameters = new PrinterParameters(printers[0]);
	parameters.setPrinterMode(PrinterParameters.LINE_MODE);
	LinePrinter printer = (LinePrinter)connector.open(parameters);

	ScalableFont font1 = (ScalableFont) printer.getFont("Scalable");
	font1.setFontSize(12);
		
	printer.printText(font1, "Center this text", LinePrinter.ALIGN_CENTER);
		
	printer.doPrint(1);
	printer.close();

 
 

Since:
MI 2.5
Author:
Abaco
See Also:
PrinterParameters, Connection, PrinterBarcode, PrinterFont

Nested Class Summary
 
Nested classes inherited from class com.sap.ip.me.api.pios.printer.PrinterConnection
PrinterConnection.Attributes
 
Field Summary
static int ALIGN_CENTER
          Constant to indicate center alignment.
static int ALIGN_LEFT
          Constant to indicate left alignment.
static int ALIGN_RIGHT
          Constant to indicate right alignment.
static int NO_ALIGNMENT
          Constant to indicate no alignment.
 
Fields inherited from class com.sap.ip.me.api.pios.printer.PrinterConnection
STATUS_BUSY, STATUS_DATA_ERROR, STATUS_FONT_NOT_AVAILABLE_ERROR, STATUS_IDLE, STATUS_INVALID_COORDINATE_ERROR, STATUS_OUT_OF_MEMORY_ERROR, STATUS_OUT_OF_PAPER, STATUS_UNKNOWN_ERROR
 
Fields inherited from class com.sap.ip.me.api.pios.connection.Connection
attributesFileName, cfgFile, opened, parameters
 
Constructor Summary
protected LinePrinter()
          Constructs a new line printer connection.
 
Method Summary
abstract  void printBarcode(PrinterBarcode barcode, byte[] data, int alignment)
          Prints a barcode at current line position.
abstract  void printImage(java.lang.String imageName, int alignment)
          Prints an image at current line position.
abstract  void printText(PrinterFont font, java.lang.String text, int alignment)
          Prints the specified text at the current line position.
abstract  void printTransientImage(java.awt.Image img, int alignment)
          Prints a transient image at current line position.
abstract  void setLineSpacing(float points)
          Sets the space between lines.
 
Methods inherited from class com.sap.ip.me.api.pios.printer.PrinterConnection
advance, clearError, createBarcode, createImage, deleteImage, dispose, doPrint, getFont, getFontConfigurationManager, getPrinterDPI, getPrintHeadWidth, getStatus, listFonts, loadImage, sendRawBytes
 
Methods inherited from class com.sap.ip.me.api.pios.connection.Connection
close, getParameters, isOpen, open
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ALIGNMENT

public static final int NO_ALIGNMENT
Constant to indicate no alignment.

See Also:
Constant Field Values

ALIGN_LEFT

public static final int ALIGN_LEFT
Constant to indicate left alignment.

See Also:
Constant Field Values

ALIGN_CENTER

public static final int ALIGN_CENTER
Constant to indicate center alignment.

See Also:
Constant Field Values

ALIGN_RIGHT

public static final int ALIGN_RIGHT
Constant to indicate right alignment.

See Also:
Constant Field Values
Constructor Detail

LinePrinter

protected LinePrinter()
               throws PIOSException
Constructs a new line printer connection.

Throws:
PIOSException - thrown if an error is detected while creating/ opening the printer connection.
Method Detail

setLineSpacing

public abstract void setLineSpacing(float points)
                             throws UnsupportedException,
                                    PrinterException
Sets the space between lines. Some printers may not support this command.

Parameters:
points - the height of the space between lines
Throws:
UnsupportedException - thrown if command not supported by the printer
PrinterException - thrown when invalid parameter value are used

printText

public abstract void printText(PrinterFont font,
                               java.lang.String text,
                               int alignment)
                        throws UnsupportedException,
                               PrinterException
Prints the specified text at the current line position. Current line is advanced to the next line after printing.

Parameters:
font - the text font
text - the text to print
alignment - the text alignment
Throws:
UnsupportedException - thrown if alignment is not supported by the printer
PrinterException - thrown if an error occurs while printing the text

printBarcode

public abstract void printBarcode(PrinterBarcode barcode,
                                  byte[] data,
                                  int alignment)
                           throws UnsupportedException,
                                  PrinterException
Prints a barcode at current line position. Current line is advanced to next line after printing.

Parameters:
barcode - the PrinterBarcode object that include information of symbology and printing options
data - the data to be encoded in barcode
alignment - the barcode alignment
Throws:
UnsupportedException - thrown if alignment is not supported by the printer
PrinterException - thrown if an error occurs while printing the barcode
See Also:
com.sap.ip.me.api.pios.symbology

printImage

public abstract void printImage(java.lang.String imageName,
                                int alignment)
                         throws UnsupportedException,
                                PrinterException
Prints an image at current line position. Current line is advanced to next line after printing.

Parameters:
imageName - the image name
alignment - the image alignment
Throws:
UnsupportedException - thrown if alignment is not supported by the printer
PrinterException - thrown if an error occurs while printing the image

printTransientImage

public abstract void printTransientImage(java.awt.Image img,
                                         int alignment)
                                  throws UnsupportedException,
                                         PrinterException
Prints a transient image at current line position. Current line is advanced to next line after printing.

Parameters:
img - the transient image to be printed
alignment - the image alignment
Throws:
UnsupportedException - thrown if alignment or printing transient images is not supported by the printer
PrinterException - thrown if an error occurs while printing the image


Copyright © 2005 SAP AG. All Rights Reserved.