Adding different barcode types (including QR codes) to your PDFs, whether for retail, pharmacy, or industrial purposes is easy with PDF Ink. Since PDF Ink, when used with WordPress, allows you to accept some user input before your PDF file is downloaded, you can even include that data in your barcode! Completely customized barcodes added on-the-fly to your PDFs, as they are downloaded… that’s pretty cool!
Barcode Types
Here are the barcode types recognized by TCPDF:
- CODE 39. Also called Alpha39, Code 3 of 9, Code 3/9, Type 39, USS Code 39, or USD-3. International standard ISO/IEC 16388) (C39)
- CODE 39 with checksum (C39+)
- CODE 39 extended (C39E)
- CODE 39 extended with checksum (C39E+)
- CODE 93 (USS-93, Canada Post)
- Standard 2 of 5 (S25)
- Standard 2 of 5 + (S25+)
- Interleaved 2 of 5 (I25)
- Interleaved 2 of 5 + (I25+)
- CODE 128. International Standard ISO/IEC 15417. (C128)
- CODE 128 A
- CODE 128 B
- CODE 128 C
- EAN 2 2-Digits UPC-Based Extension. European Article Number. Magazines. (EAN2)
- EAN 5 5-Digits UPC-Based Extension. Books. (EAN5)
- EAN 8. International Standard ISO/IEC 15420 (EAN8)
- EAN 13. International Standard ISO/IEC 15420 (EAN13)
- Universal Product Code (UPC-A)
- UPC-E
- MSI. Modified Plessey. Warehouse use.
- MSI+
- POSTNET Old USPS barcode
- PLANET Old USPS barcode, retired 2013
- Royal Mail 4-state Customer Code – Customer Bar Code (RMS4CC)
- Klant index – Customer index – PostNL (KIX)
- Intelligent Mail Barcode – Onecode – USPS-B-3200 – United States Postal Service (IMB)
- Pre-processed Intelligent Mail Barcode, using only F,A,D,T letters (IMBPRE)
- CODABAR. Library use.
- CODE 11. Telecommunications.
- PHARMACODE. Pharmaceutical use
- PHARMACODE TWO-TRACKS (PHARMA2T)
- DATAMATRIX
- PDF417 International standard: ISO/IEC 15438. (PDF417 + a[aspect ratio (width/height)],e[error correction level (0-8)],t[total number of macro segments],s[macro segment index (0-99998)],f[file ID],o0[File Name (text)],o1[Segment Count (numeric)],o2[Time Stamp (numeric)],o3[Sender (text)],o4[Addressee (text)],o5[File Size (numeric)],o6[Checksum (numeric)])
- QRCODE. International Standard: ISO/IEC 18004
- QRCODE,L. Low error correction (7%).
- QRCODE,M. Medium error correction (15%).
- QRCODE,Q. Quartile error correction (25%)
- QRCODE,H. High error correction (30%)
- RAW. Comma-separad list of array rows
- RAW2. Array rows are surrounded by square parenthesis.
- TEST. Test matrix.
Your barcodes can be any size, any color, printed anywhere on the page. You can have two completely different barcodes printed on each page. The barcodes are configurable using TCPDF parameters, most of which are included in the settings panel. More advanced settings can be added using the TCPDF barcode $style PHP array() (detailed below) via a text field in the settings.
Barcode Settings
In order to add barcodes to your PDFs, you need to be using the TCPDF library. (This feature is road-mapped for SetaPDF-Stamper.)
Barcodes replace placement content saved in the settings. There are up to four native placements in the Frontend and Sandbox settings. So naturally, you can easily have up to four barcodes on each page. If you need more, it’s easy to add more placements using a couple lines of PHP.
Under each placement contact field is a checkbox:

As it says, checking the box will convert content into a barcode. So if you want to barcode an address, enter the address into the Content field. Now click the “Customize your barcode” link and a popup will show:

Keep in mind we are using metric, but now we are using centimeters, not millimeters as we were in the PDF Ink margins and y-adjustment settings!
Once you fill out the settings, X out the popup box and save them on the main screen. Test barcoding until you have it dialed in
The Barcode Style Array
In the barcode settings is a field labeled “Barcode style array.” This is an optional, but useful field. If you need to tailor your barcode, then this is probably how to do it.
Below are the parameters, usually passed in an array. You will enter them as a comma-separated string. What string you enter depends on whether you are using a 1D or 2D barcode. What’s the difference between a 1D and a 2D barcode? It depends on whether data is read in one direction, or two.

On the left, a 1D barcode. Data is read horizontally via bars of differing width. On the right, a 2D barcode; data is read horizontally and vertically. You may be familiar with the 2D barcode, as QR codes have become a popular means of distributing branding and marketing via smartphones and other readers. Adding a barcode to your PDF is not only great way to make your PDFs look “cool” and add function, but it can also give the end user the impression that you take your data seriously (even if you don’t). Flex!
1D Barcodes
1D barcode types are: ‘C39’, ‘C39+’, ‘C39E’, ‘C39E+’, ‘C93’, ‘S25’, ‘S25+’, ‘I25’, ‘I25+’, ‘C128’, ‘C128A’, ‘C128B’, ‘C128C’, ‘EAN2’, ‘EAN5’, ‘EAN8’, ‘EAN13’, ‘UPCA’, ‘UPCE’, ‘MSI’, ‘MSI+’, ‘POSTNET’, ‘PLANET’, ‘RMS4CC’, ‘KIX’, ‘IMB’, ‘IMBPRE’, ‘CODABAR’, ‘CODE11’, ‘PHARMA’, and ‘PHARMA2T’.
1D barcode $style (array) parameters:
border (boolean) | If true, prints a border |
padding (int) | Padding to leave around the barcode in user units (set to ‘auto’ for automatic padding) |
hpadding (int) | Horizontal padding in user units (set to ‘auto’ for automatic padding) |
vpadding (int) | Vertical padding in user units (set to ‘auto’ for automatic padding) |
fgcolor (array) | Color array for bars and text |
bgcolor (mixed) | Color array for background (set to false for transparent) |
text (boolean) | If true prints text below the barcode |
label (string) | Override default label |
font (string) | Font name for text |
fontsize (int) | Font size for text |
stretchtext (int) | 0 = disabled; 1 = horizontal scaling only if necessary; 2 = forced horizontal scaling; 3 = character spacing only if necessary; 4 = forced character spacing. |
position (string) | Horizontal position of the containing barcode cell on the page: L = left margin; C = center; R = right margin. |
align (string) | Horizontal position of the barcode on the containing rectangle: L = left; C = center; R = right. |
stretch (string) | If true stretch the barcode to best fit the available width, otherwise uses $xres resolution for a single bar. |
fitwidth (string) | If true reduce the width to fit the barcode width + padding. When this option is enabled the ‘stretch’ option is automatically disabled. |
cellfitalign (string) | This option works only when ‘fitwidth’ is true and ‘position’ is unset or empty. Set the horizontal position of the containing barcode cell inside the specified rectangle: L = left; C = center; R = right. |
2D Barcodes
2D barcode types are: ‘DATAMATRIX’, ‘PDF417(a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6)’, ‘QRCODE’, ‘QRCODE,L’, ‘QRCODE,M’, ‘QRCODE,Q’, ‘QRCODE,H’, ‘RAW’, ‘RAW2’, and ‘TEST’.
2D barcode $style (array) parameters:
border (boolean) | If true, prints a border |
padding (int) | Padding to leave around the barcode in user units (set to ‘auto’ for automatic padding) |
hpadding (int) | Horizontal padding in user units (set to ‘auto’ for automatic padding) |
vpadding (int) | Vertical padding in user units (set to ‘auto’ for automatic padding) |
module_width (int) | Width of a single module in points |
module_height (int) | Height of a single module in points |
fgcolor (array) | Color array for bars and text |
bgcolor (string) | Color array for background or false for transparent |
position (string) | Barcode position on the page: L = left margin; C = center; R = right margin; S = stretch |