Skip to content

Resizing Symbols

Terry Burton edited this page Sep 28, 2022 · 8 revisions

Resizing Symbols

To create a barcode of some required width and height (without stretching the text) perform the following steps, in order.

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 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.

Clone this wiki locally