How can the DPI be increased to print very small barcodes accurately?
What print resolutions do the Servlet or JPEG encoder support
and how are these set?
How can the barcode size be adjusted if the dimensions are not
accurate? For example: 1cm does not equal 1cm?
Most web browsers print from the screen image at 38 dots per cm or 96
DPI. In addition, JDK 1.1 to 1.2 applications always print at 96 DPI.
However, the limitations can be solved in a few different ways:
If the Java Servlet
is used - The Servlet creates a JPEG image at 300 DPI resolution
in the web browser. However, the web browser views this at 96 DPI.
Since the IMG tag is used to embed the Servlet into HTML, it may
be compressed or expanded as necessary. The minimum X dimension
(narrow bar width) of the Java barcode is usually .03 cm (about
10 mils or 1/96"), and because the viewing area is reduced, the
X dimension will be .015 cm or about 5 mils. Remember, because the
screen resolution is 96 DPI, it will not look correct on the screen
but it will print correctly because most printers have a DPI of
300 or more. For example, the code below reduces the image by 50%: <IMG height=40 alt="Barcode Image"
If JDK 1.3 or greater is being used and printing from the
Java application itself - The printer resolution may be set.
Refer to the java.awt.PageAttributes.setPrinterResosution()
in the JDK1.3 documentation.
JDK 1.3 Example - An example of an application that prints
with printer resolution and uses Java 2 (JDK 1.3) is in IDAutomation's
Maxicode Java Package and
may be downloaded here. The file ApplicationExample.java is
the file in the package to view.
When creating images for graphic applications, set the
resolution to 118 to create a 300 DPI image.
The resolution used to convert to pixels can be changed
by using the method setPixelsPerCM(int) or resolution(int).
By default this value is the screen resolution of pixels per cm.
If resolution is set to 1, then 1 cm will equal 1 pixel.