How To Print Labels Through PHP Application
Azoft Blog How To Print Labels Through PHP Application

How To Print Labels Through PHP Application

By Konstantin Medvedev on December 12, 2012

In this article, we'd like to share our experience integrating a PHP web application with BarTender Print Server. This information could be useful to anyone planning to automate the process of printing labels, bar codes or RFID tags and to integrate the necessary equipment with existing enterprise systems. The article concerns PHP applications, since they are frequently used as commercial business systems. But keep in mind that the method we describe here can also be employed for applications based on other platforms.

BarTender software consists of many utilities. We will need following:

  1. BarTender Print Server — basic application of the software, employed for creating and printing labels.

  2. Commander — a utility that allows to automatically create print tasks in BarTender through other applications. Whenever the application needs to print something, it performs a trigger action, which initializes the printing process. For instance, the application may place a data file that needs to be printed in a particular place within the network or send a message over TCP/IP protocol. The Commander would then detect those triggers and 'wake-up' BarTender in order to launch printing.

  3. License Server monitors and allows using the maximum allowed number of printers. It automatically runs in the background on any computer of the network.

BarTender Print Server includes embedded drivers for working with databases such as Oracle, MS SQL, and .NET platform. However, it is not compatible with PHP web applications. In order to make working with PHP applications possible, we'll make use of the Commander.

Let's take a step-by-step look at how to set-up BarTender's utilities for working with a PHP-application.

With the exception of the image, all other fields of the label are dynamic. Data for dynamic fields will be transmitted through an intermediate data file. The file scanned in Commander's directory will act as a trigger event, initializing launching of BarTender.

First, we should create an intermediate data file C:\print\data.dat. First line should contain the field's name while the second should contain the data. For example:

Customer      ProductName  ProductNumber  Date ….

Customer 1  Product 1          1234567890        05/06/2012 12:23:32

If we double-click label's field, we can change settings and also set a data source. To do this, let's choose “Database Field” tab.

By clicking Database Connection Setup, we will launch the process of adding a connection with the database. Then, following the instructions, select Text File as a database type and enter the file we created C:\print\data.dat. Fields' headers will act as TAB separation and the first record in text file. If done correctly, BarTrender will parse the file and enter fields' headers into the directory.

Then we will only select required entry in the directory to automatically enter data in each label's field while printing.

At this point, the settings for our label are ready. Here we only need to save our template as C:\print\template.btw.

Step 2: Now let's look at how to setup the Commander.

First, in Task Menu click Add. Then enter task name and trigger File. In Trigger tab, choose the folder that needs to be scanned C\:print and as a response to detection choose Delete File.

Then in Commands tab click ... . In a pop-up window in the field Format(s) to Use we should enter the file with label's template we prepared earlier, called C\:print\template.btw. Save the task.

In the upper menu of Commander, choose Start Detection or launch by pressing CTRL+R. Now the system is ready to print.

To experiment, we can try the following: if we create file startPrint.dd by hand in folder C\:print, then Commander will automatically initialize printing of label.

To launch printing through a PHP application we need to enter all data necessary for printing in the file data.dat as well as create a file with extension *.dd.

As you can see, this method of printing labels can be employed not only through PHP-application. Applying this method, you can initialize printing through any other programming tool.

The integration of PHP applications with BarTender Print Server opens great opportunities for automation of business processes in retail facilities, trading chains, warehouses, large-scale department stores, entertainment venues, etc. Not to mention, such integration provides useful solutions for creating and printing your own unique labels.

In this article we described the most straight-forward method of printing. We didn't examine cases when printing is launched by several users, working with several printers, since that would require a more involved approach.

VN:F [1.9.22_1171]
Rating: 4.7/5 (12 votes cast)
VN:F [1.9.22_1171]
Rating: +5 (from 5 votes)
How To Print Labels Through PHP Application, 4.7 out of 5 based on 12 ratings

Request a Free Quote

Please enter the result and submit the form

Content created by Konstantin Medvedev