PixelBinary
A font that turns a PDF form field into a QR code or a Data Matrix code. Type into the form and the barcode redraws itself — no plug-in, no server, no picture.
A barcode is just text
Barcodes in PDF forms are usually sold as a plug-in or a paid add-on. They do not have to be. A QR code or a Data Matrix code is a grid of black and white squares, and PixelBinary is a font with exactly two shapes: the character 1 is a black square, the character 0 is a white square of the same size, and there is no space between characters or between lines.
So this text, shown in the font, is the top-left corner of a QR code:
1000001011
1011101011
1011101000
1011101010
1000001000
1111111010
A script inside the PDF turns whatever somebody types into those rows of 0 and 1, and an ordinary read-only text field that uses the font shows them. That is the whole trick. The code changes the moment the text changes, and it is still there when the form is printed or saved.
The example form: one text field, two barcodes made from it
What is in the download
| File | What it is |
|---|---|
| PixelBinary-Barcode-Example.pdf | The example form. Type a text, click outside the field: both codes are redrawn. |
| PixelBinary-010101.otf | The font: 0 is an empty square, 1 to 9 are a filled square. |
| PixelBinary-Tall135.ttf | A companion font for PDF viewers that space the lines of a text field differently (see Which PDF programs run it). |
| PixelBinary-script.js | The script of the example, ready to paste into your own form. |
| README and licenses | How to use it, and the two short licenses. |
To put a barcode into a form of your own, follow Add a barcode to your own form.
Download
Free for any use, at home or at work.
Fonts, example form, script and licenses. About 50 KB.
SHA-256: 261B100F20C7AF52C6E633CE73E50AFD76178A21CCD496F376192410BB5D297D
Only want to look? Open the example PDF — and save it to your computer first: the PDF viewer built into a web browser may not run its script.
Where it works
The barcode is redrawn by JavaScript inside the PDF, so it depends on the program you open the form with:
| PDF program | What happens |
|---|---|
| Adobe Acrobat, Acrobat Reader (Windows, macOS) | The programs it was made for. The barcodes follow the text as you leave the field. |
| DocuWrit 0.4 and later (free) | Asks before it runs the script; then the barcodes follow the text as you leave the field. |
| Firefox and other viewers built on pdf.js | The script runs. After a change the screen shows the rows of 0 and 1; the barcode itself is drawn when you print or save the form. |
| Viewers without form JavaScript (many phone and browser viewers) | They show the barcode that was saved in the file. It does not change when the text changes. |
Details and fixes: Which PDF programs run it.
What it does not do
- It is not a barcode product with support. It is a font, a script and an example. Scan every code you are going to depend on.
- QR Code and Data Matrix only. No Code 128, no PDF417, no Aztec.
- Short texts. The example accepts up to 200 characters; longer texts need a bigger field or smaller squares.
- Plain characters. Text is encoded as Latin-1 bytes. Test anything outside it with your scanner.
- You need a PDF editor to build your own form — one that can add form fields, embed a font and add JavaScript.
License and credits
Use it, change it, put it in your own forms and products — no charge, no registration.
The two fonts are under the SIL Open Font License 1.1: use them anywhere, embed them in any document, change them; a changed font must stay under the same license and must not be sold by itself. The scripts are under the MIT License. Both license texts are in the download.
PixelBinary is three pieces of other people's work and a little glue, and the credit belongs to them:
| Part | By | License |
|---|---|---|
| Data Matrix encoder: tualo-datamatrix | tualo solutions GmbH (Thomas Hoffmann) | MIT |
| QR Code encoder: quickresponse() from 2D barcode symbol creation by javascript | Alois Zingl | MIT |
| The PixelBinary fonts | Trilaworks (2006), JimRan Software | SIL OFL 1.1 |
| The glue script and the example form | JimRan Software | MIT |
“QR Code” is a registered trademark of DENSO WAVE INCORPORATED.
To open, fill and build PDF forms you can use DocuWrit, our free, open-source PDF filler and editor.