Generate .PRN file template using ‘BarTender’ software and print the barcode label using PHP.

SANTHIYA SUGUMAR
2 min readMar 8, 2021

--

This article describes how to generate a barcode template i.e generate .PRN file using “BarTender Software”.

Step-by-step Guide

Step 1: Download and Install the BarTender Software in your system.

Step 2: Open the BarTender document with the custom specifications.

Step 3: Click the Barcode icon on the BarTender toolbar. Choose the More Barcodes option to open the barcode selector. Search or browse for the specific barcode that you’d like to add.

Step 4: Once you’ve found it, click the barcode to highlight it and then click Select. Click anywhere on your template to add the barcode. To move and resize the barcode by using the mouse.

Step 5: Click the print icon on the BarTender toolbar. A print popup window will appear, enable the ‘Print to File’ and click the Print button.

Step 6: Enter a file name( browse the location where you want to save the . PRN File), then click Print.

Step 7: Using the following PHP code, print the barcode label in the printer. Place the Output.prn file along with php code.

<?php error_reporting(E_ALL);

printBarcode(“1234”, “Pencil”);

function printBarcode($bookcode, $product_name){

$val = ‘

<xpml><page quantity=”0" pitch=”152.4 mm”></xpml>SIZE 101.6 mm, 152.4 mm

DIRECTION 0,0

REFERENCE 0,0

OFFSET 0 mm

SET PEEL OFF

SET CUTTER OFF

SET PARTIAL_CUTTER OFF

<xpml></page></xpml><xpml><page quantity=”1" pitch=”152.4 mm”></xpml>SET TEAR ON

CLS

BARCODE 642,848,”128M”,166,0,180,6,12,”!10512345678"

CODEPAGE 1252

TEXT 473,676,”ROMAN.TTF”,90,1,12,”’.$bookcode.’”

TEXT 311,326,”ROMAN.TTF”,90,1,29,”’.$product_name.’”

PRINT 1,1

<xpml></page></xpml><xpml><end/></xpml>’;

file_put_contents(“Output.prn”,trim($val));

$cmd = ‘COPY \Output.prn \\\MY-PC\BARCODE’;

//COPY <source> <printer_name>

echo $cmd;

system($cmd);

}

?>

--

--

No responses yet