Next: , Previous: , Up: The Barcode Object  


2.1 The Fields

int flags;

The flags are, as you may suspect, meant to specify the exact behaviour of the library. They are often passed as an argument to barcode functions and are discussed in the next section.

char *ascii;
char *partial;
char *textinfo;
char *encoding;

These fields are internally managed by the library, and you are not expected to touch them if you use the provided API. All of them are allocated with malloc.

int width;
int height;

They specify the width and height of the active barcode region (i.e., excluding the white margin), in the units used to create output data (for postscript they are points, 1/72th of an inch, 0.352 mm). The fields can be either assigned to in the structure or via Barcode_Position(), at your choice. If either value or both are left to their default value of zero, the output engine will assign default values according to the specified scaling factor. If the specified width is bigger than needed (according to the scaling factor), the output barcode will be centered in its requested region. If either the width of the height are too small for the specified scale factor, the output bar code will expand symmetrically around the requested region.

int xoff;
int yoff;

The fields specify offset from the coordinate origin of the output engine (for postscript, position 0,0 is the lower left corner of the page). The fields can be either assigned to in the structure or via Barcode_Position(), at your choice. The offset specifies where the white margin begins, not where the first bar will be printed. To print real ink to the specified position you should set margin to 0.

int margin;

The white margin that will be left around the printed area of the bar code. The same margin is applied to all sides of the printed area. The default value for the margin is defined in barcode.h as BARCODE_DEFAULT_MARGIN (10).

double scalef;

The enlarge or shrink value for the bar code over its default dimension. The width and scalef fields interact deeply in the creation of the output, and a complete description of the issues appears later in this section.

int error;

The field is used when a barcode function fails to host an errno-like integer value.

Use of the width and scalef fields.

A width unit is the width of the thinnest bar and/or space in the chosen code; it defaults to 1 point if the output is postscript or encapsulated postscript.

Either or both the code width and the scale factor can be left unspecified (i.e., zero). The library deals with defaults in the following way:

Both unspecified

If both the width and the scale factor are unspecified, the scale factor will default to 1.0 and the width is calculated according to the actual width of the bar code being printed.

Width unspecified

If the width is not specified, it is calculated according to the values of scalef.

Scale factor unspecified

If the scale factor is not specified, it will be chosen so that the generated bar code exactly fits the specified width.

Both specified

The code will be printed inside the specified region according to the specified scale factor. It will be aligned to the left. If, however, the chosen width is too small for the specific bar code and scaling factor, then the code will extend symmetrically to the left and to the right of the chosen region.


Next: , Previous: , Up: The Barcode Object