saveSimpleImage / saveImage Method

Generates a barcode image and saves it to a file. saveSimpleImage is lightweight and is the recommended method for saving an image. saveImage uses more resources and requires your web server to run in graphics mode (e.g. X-Window) but it allows you to use the fonts of your choice.

Syntax

public void saveSimpleImage(int imageType, int width, int height, 
	boolean isBarWidth, String pathFile) 
	throws Exception

public void saveSimpleImage(int imageType, int width, int height, 
	boolean isBarWidth, int scale, String textOnly, String pathFile)
	throws Exception
AWT Version
public void saveImage(int imageType, int width, int height, 
	boolean isBarWidth, String pathFile) 
	throws Exception

public void saveImage(int imageType, int width, int height, 
	boolean isBarWidth, int scale, String textOnly, String pathFile)
	throws Exception

Parameters

imageType

Indicates the image format:

width

Specifies either the desired width for the entire barcode or the width of the thinnest bar, in screen pixels, depending on the value of the isBarWidth parameter. Typically, it's more convenient to specify the width of the thinnest bar rather than that of the entire barcode.

height

Specifies the height of the barcode in screen pixels.

isBarWidth

If true, it indicates that the width parameter is the width of the tinnest bar; otherwise, it's the width of the entire barcode.

scale

This is typically one. If greater than 1, the entire image is scaled by this factor relative the specified width and height parameters and the font size.

textOnly

If not null, the text it represents will be drawn instead of a barcode. In this case, you can specify 0 for both the width and the height parameters and the actual size of the image will be computed automatically to fit the text.

filePath

Specifies the file path to which the barcode image is to be saved.

Remarks

The roles of the width and height parameters are inversed if the barcode orientation (setOrientation) is 90 or 270 degrees.

If the file already exists, it's overwritten; otherwise, a new file is created.