Skip to content

Resizing Symbols

Terry Burton edited this page Apr 7, 2026 · 13 revisions

Resizing Symbols

There are several ways to control the size of a barcode symbol:

  • Manual scaling — apply a uniform PostScript scale and adjust bar height to compensate. Works with any symbology but requires arithmetic.
  • For linear barcodes, propspec — automatically adjusts bar height to the specification's proportions while keeping an X-dimension that is normalised to 1pt. Ensures that bitmap-based outputs are pixel-locked.
  • loosespec — for vector-based outputs with real-world dimensions, will render at correct physical dimensions for known applications (asts) automatically. Alternatively both X-dimension (xdim) and bar height (hdim) may be specified directly. If neither the application is known nor user-provided dimensions given then will fall back to default nominal dimensions.
  • strictspec — as with loosespec, except that it will raise an error if (1) the effective X-dimension does not meet any xmin and xmax bounds defined by the application (ast), and (2) if the application does not provide nominal xnom and hnom metrics.

See Symbol Dimensions for full reference documentation.

Manual scaling

The width option stretches the symbol (including text) non-uniformly, which distorts human-readable text. To resize without distortion, apply a uniform scale and adjust bar height to compensate.

Starting with this example:

0 0 moveto (9520123456788) (includetext)
/ean13 /uk.co.terryburton.bwipp findresource exec

Original barcode

Find the uniform (same x and y) scale factor that makes your output of the required width:

gsave
2 2 scale      %  <-- Add a line like this
0 0 moveto (9520123456788) (includetext)
/ean13 /uk.co.terryburton.bwipp findresource exec
grestore

Uniformly scaled barcode

Add a height option (in inches) that adjusts the bar height appropriately, taking the scaling into account:

gsave
2 2 scale
% Added height=0.8 option to adjust height
0 0 moveto (9520123456788) (includetext height=0.8)
/ean13 /uk.co.terryburton.bwipp findresource exec
grestore

Truncated barcode

The result should now be of the intended dimensions with properly scaled (not stretched) text.

To create a linear barcode having an X-dimension of X mm and height of H mm:

scale  = (72 * X) / 25.4
height = H / (72 * X)

The propspec and strictspec options described below automate this calculation using the symbology's specification data.

Using propspec for specification-proportional output

Instead of computing bar heights manually, the propspec option adjusts bar height to match the specification's height-to-width ratio, pixel-locked to whole points. The coordinate system stays at 1 point per module so external scaling still controls the X-dimension:

gsave
2 2 scale
0 0 moveto (9520123456788) (includetext propspec)
/ean13 /uk.co.terryburton.bwipp findresource exec
grestore

The bar height is derived from the symbology's Application Specification Table. Named profiles can be selected for specific application contexts:

gsave
2 2 scale
0 0 moveto (9520123456788) (includetext propspec ast=gs1.sst2)
/ean13 /uk.co.terryburton.bwipp findresource exec
grestore

This is useful for workflows where the caller does not control the PostScript interpreter directly (e.g. EPS files processed by a third-party RIP) — the correct proportions are baked into the symbol regardless of the rendering resolution.

Notes

  • Linear barcodes only. For 2D symbologies, use loosespec or strictspec.
  • If the user also supplies an explicit height, it acts as a multiplier on the derived height (e.g. height=1.5 for 150% of spec height).
  • If the symbology has no specification height data, propspec is a harmless no-op — bar height falls back to the encoder's default.

Using loosespec or strictspec for physical output

For workflows where the caller controls the PostScript interpreter, loosespec and strictspec render the symbol at its correct physical dimensions automatically, including both X-dimension and bar height. No external scaling is needed.

loosespec silently falls back to default dimensions when specification data is incomplete. strictspec is the strict variant — it raises an error when specification data is missing or the effective X-dimension is outside bounds.

An EAN-13 at specification dimensions using loosespec:

0 0 moveto (9520123456788) (includetext loosespec)
/ean13 /uk.co.terryburton.bwipp findresource exec

A QR Code at specification dimensions using loosespec:

0 0 moveto (Hello World) (loosespec)
/qrcode /uk.co.terryburton.bwipp findresource exec

Use mag to scale relative to the nominal specification dimensions with strictspec:

0 0 moveto (9520123456788) (includetext strictspec mag=1.5)
/ean13 /uk.co.terryburton.bwipp findresource exec

Select an Application Specification Table profile for a specific application context with strictspec:

0 0 moveto (9520123456788) (includetext strictspec ast=gs1.sst2)
/ean13 /uk.co.terryburton.bwipp findresource exec

To specify exact physical dimensions directly, use xdim and hdim (in millimetres) with strictspec:

0 0 moveto (9520123456788) (includetext strictspec xdim=0.400 hdim=25.0)
/ean13 /uk.co.terryburton.bwipp findresource exec

For bitmap output, combine loosespec with gridfit to align module boundaries to the device pixel grid:

0 0 moveto (9520123456788) (includetext loosespec gridfit griddpi=300)
/ean13 /uk.co.terryburton.bwipp findresource exec

Clone this wiki locally