25.5. Adjusting the output

This section deals with the way you can adjust the visual quality and appearance of the output by adjusting a number of properties on the backend.

25.5.1. Output format

By choosing the appropriate backend you can choose to generate the barcode label as either an image (in either PNG or JPEG format) or as Postscript (both standalone and Encapsulated postscript) . For images the PNG is strongly recommended and used by default. The reason is that PNG is a non-destructive format and will ensure the maximum quality of the barcodes while JPEG is not well suited for this type of applications since it is a destructive format.

This choice is being made by creating the appropriate backend. The backend is created by calling the factory method PDF417BackendFactory::Create() specifying what type of backend and what encoder to use. The backend factory will then return a suitable encoder.

The following code snippet shows how to create a backend that will generate an image.

1
2
3
4
5
6
<?php
// Create a new encode using the default error correction
// and columns
$encoder = new PDF417Barcode ();
$backend = PDF417BackendFactory::Create( BACKEND_IMAGE, $encoder);
?>

It is also possible to have one encoder and two different backends to allow the creation of both image and postscript output at the same time as the following example shows

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$date='ABC123';
$file=' ...'; // Some filename to write the PS file to
 
// Create a new encode using the default error correction
// and columns
$encoder = new PDF417Barcode ();
 
$eImg = PDF417BackendFactory::Create( BACKEND_IMAGE, $encoder);
$eEPS = PDF417BackendFactory::Create( BACKEND_EPS, $encoder);
$eEPS->Stroke($data,$file);
$eImg->Stroke($data);
?>

25.5.2. Summary of user settings for the backend

In the list below is a short description of the available possibilities to change the output. For a more detailed explanation of the parameters for each method please consult the method reference at the end of this chapter

  • Specifying the module width. The module width for the barcode is user selectable, For images this specifies the number of pixels for the module and for Postscript output this specifies the number of points (1/72 inch).

  • Specifying the width/height factor Specify the height of each individual row in the barcode as a multiple of the width. By default the height is 3x the width.

  • Specifying background and foreground color The foreground color and the background color for the barcodes are user selectable. The colors can be specified as any of JpGraphs builtin colors.

  • Adding human readable text This is an extension to the PDF417 standard. This adds a plaintext string of the data that has been encoded under the barcode. This is useful when debugging applications to make sure that the right values have been read, for example, from a DB.

  • Rotating 90 degrees (Vertical output) This enables the barcode to be printed vertically.

  • Scaling the image The resulting barcode images can be scaled by an arbitrary factor.