Forums

BARCODE in PDF

K2Joom 16 Dec, 2014
Hello Clever Peeps.

I have a form, which upon save, creates a PDF, all very good.
Now I want to try and get the text from the fields, not the labels, to be converted and displayed as Code39 barcode.

The intention being to consider using Joomla! to automate the creation of production job sheets in a manufacturing environment, whilst allowing job data to be saved to DB for later viewing.
Being able to output the data as barcodes in the PDF would be great.

For anyone else that is interested, I have seen this link and use it as a reference: http://greyhead.net/chronoforms/adding-a-barcode-to-a-form-e-mail which is great, but discusses the creation of a random identifier. Our data is known, so needs to be handled differently.
Now this also includes link to a php based barcode generator http://www.sid6581.net/cs/php-scripts/barcode/
The only downside to the above generator, could be that it does not generate images.

If you are interested in a barcode generator that does create images, then this could be a good solution: http://example.barcodephp.com/html/BCGcode39.php the additiona beauty of this generator is that you can decide on size, thickness, output image type and barcode type. It does however come at a cost if you want server side scripts😟
This is also true for the likes of ID Automation, whom I use for their desktop barcode font.

If we can get data converted to barcodes and saved as images, then embedded in the PDF, that would be fantastic.

There is also this resource: http://www.shayanderson.com/php/php-barcode-generator-class-code-39.htm
In the explanation, they output the code as follows:
// set object 
$bc = new Barcode39("123-ABC"); 

This would display 123-ABC as the barcode.

Would I be right in thinking that the PDF template could just use the relevant field tags, such as {barcode1} to display the data for that field and add their custom code in the form.

Will be testing this and updating with information to help the community.
GreyHead 16 Dec, 2014
Hi Simon,

It's a few years since I wrote the FAQ but I think I'm right in saying that the free library I used does create an image (check the on-line form there to see one); the image can include your custom code instead of a random string - just replace that part of the script.

The one part I am unsure about is including an image using the tcpdf action. You'd need to check that works OK. TCPDF can handle it but the action is a wrapper round wht TCPDF code with limited functionality.

Bob
K2Joom 16 Dec, 2014
An Update.

I decided to try http://www.shayanderson.com/php/php-barcode-generator-class-code-39.htm

Steps taken so far:
1) Download the file
2) Extract the file
3) Via FTP goto components/com_chronoforms and create a new folder called includes
4) Upload the Barcode39.php file
5) Copy index.html into the includes folder.
6) Check Joomla System Info to check for GD Library. Login to Admin and navigate to index.php?option=com_admin&view=sysinfo
7) Search for GD Support and ensure that it is enabled, if not, speak to your webhost.

Now looking through the Barcode39.php, I find, near the end of the file:
// check if writing image
		if($filename) {
			imagegif($img, $filename);
		// display image
		} else {
			header("Content-type: image/gif");
			imagegif($img);
		}


Now this is were I fall over, I just don't have the experience to understand how to code this.

As there are going to be 5 or 6 barcodes per pdf, I wonder if it is best to save the images with the form ID and field ID to help trace them when they are saved on the server, then link them into the PDF.

Off for coffee and more thinking.
This topic is locked and no more replies can be posted.