How to read the barcode by using the php
Steps done
I have generate the barcode by using the tcpdf scripts.
require_once(dirname(__FILE__).'/tcpdf_barcodes_1d_include.php');
// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');
// output the barcode as SVG image
$barcodeobj->getBarcodeSVG(2, 30, 'black');
[http://www.tcpdf.org/examples/barcodes/example_1d_svg.svg]
But i don't know how to read the normal Barcode Image by using php.
And also i don't exactly what the barcode reader produces after scanning the barcode.But While surfing the sites i have seen that it will produce an output of 1-2-3-4 while scanning the barcode denoting the 1234. Please correct me if the output of the barcode reader differs from what i told
In cases like this. Don't you use a barcode scanner to scan the image and it handles the job of decoding? Only thing you have to do is save the code somewhere
When the code is scanned and given to the server, it will search for that code and thats how it goes.
This is the reason almost all libraries like this don't include a read/decode functionality.
Related
We have a enveloping machine that is able to read optical character recognition codes (OMR). See: http://en.wikipedia.org/wiki/Optical_character_recognition
For that we want enrich our PDF output with such an OMR code. We use FPDF in PHP to generate our documents.
Is there a way to greate these codes maybe as a picture?
Thanks a lot!
Perhaps you could insert images into your PDF that your OMR enveloping machine could read.
If so, I can recommend this FPDF Script which writes out standard HTML which can include images into the PDF being created:
http://fpdf.org/en/script/script42.php
$pdf->WriteHTML("<img src="http://www.example.com/OMR_readable_image.gif">");
If you need to dynamically create images with page numbers, I can see a solution where you combine a circle background image with the page number text to create an image that you then use as your image source.
How to create an image dynamically:
http://www.php.net/manual/en/image.examples-png.php
This is my PDF code below:
$this->SetFillColor(0);
$this->SetTextColor(255,255,255);
$this->Cell(90,10,$airline_name,'LRBT',0,'L',true);
$this->Cell('10',10,'','',0,'L',false);
$this->SetFillColor(255,255,255);
$this->SetTextColor(0);
$this->SetFont('Times','',10);
$this->MultiCell(90,5,$com_info,1,'L',false);
$this->Ln(0);
$this->SetY(23);
$this->Cell(30,10,"MAWB",'LTB',0,'L',false);
$this->Cell(60,10,$mawb,'TRB',0,'L',false);
$this->Cell(10,10,'','',0,'L',false);
$this->Cell(45,20,'This Pieces No.\n$pn','LR',0,'L',false);
$this->Cell(45,20,'Total Pieces\n$pn','R',0,'L',false);
$this->ln(0);
$this->SetY(36);
$this->Cell(30,10,"Booking_ref",'LTB',0,'L',false);
$this->Cell(60,10,$booking_ref,'TRB',0,'L',false);
$this->Cell(10,10,'','',0,'L',false);
$this->Cell(25,20,'HAWB','LTR',0,'L',false);
$this->Cell(65,20,$quotation_no,'TR',0,'L',false);
According to above code, the PDF is as shown below:
pdf image No.01
Basically, I want to do display it as shown here:
pdf image No.02
In the PDF, the data will come from the database.
I would like to display like pdf image No.02 But i have done like pdf image No.01.
How to get the pdf image like pdf image No.02.
How can I solve it? Please help.
Not overly familiar with fPDF. It looks OK for quick, simple stuff.
Have you tried using R&OS ezPDF Creator instead - not sure what state of development/maintenance it's in these days but I think it may give you more detailed control for the kind of output you want.
I've used it for years for bespoke PDF output from PHP.
Just checked and it looks like it's still being maintained - see:
http://sourceforge.net/projects/pdf-php/
Cheers,
Arthur
I have tried fpdf and a few other libraries for a big job i have done a couple of years back. You might want to look at dompdf, the library takes html and converts it into pdf flawlessly (after a couple of tries to get it right, but still) - only thing is, read the docs - images (like your barcode there) must be linked with server path, i.e. /path/to/image/image.jpg
Basically it looks ok. Its just a bunch of little things to adapt. e.g. setting the font to bold is done via $pdf->SetFont('Arial','B',14); before the output statement and setting it back to $pdf->SetFont('Arial','',14); afterwards. See fpdf documentation for details.
I've converted hello world to QR Barcode image but my question is about getting the text back.
I mean if I sent that image to my friend, then is there any way that my friend get it back to text without using mobile reader/barcode reader machine .etc. so is there any PHP function can do this?!
If not then is there any idea I can convert text to encoded image then with PHP function whatever! I can get it back to text?!
There are several web based QR decoders. Your friend can just upload the image and the service will tell her what the code says.
One of the most popular is ZXing - http://zxing.org/w/decode.jspx
There are also others at
http://www.onlinebarcodereader.com/
http://www.patrick-wied.at/static/qrgen/
I use the ZBar bar code reader on linux (there's also a Windows and an iPhone binary), which can scan them using any supported video in device or a number of file formats (e.g., directly from PDF). It's also useful if you want to script the QR code processing.
E.g.,
$ zbarimg http://i.stack.imgur.com/pQV0s.png
QR-Code:hello world
I have following problem. I have txt file here : http://ch1zra.com/d2/runes.txt
I use PHP to loop throgh the file and generate this table : http://ch1zra.com/d2/runes.php
Table uses some basic styles and I like it that way.
txt file is generated and uploaded via python. I would like to create an image that looks like that table. Is there any way using python or PHP to do so ?
Any image format that is acceptable on the web is good, PNG being even quite welcome.
I've read somewhere that python reportlab can make styled tables with alignments and so on, so that could be a good start, but reportlab generates PDF. Of course, if that is just a step between it is also acceptable (if I could do the PDF > img conversion on my machine). ALso, IIRC every PDF contains a "screenshot" of each page for fast browsing, so that would also be cool.
All in all, I have this txt file and this HTML table that I want as image. If any1 can help that would be great :)
thanx in advance!
I can only speak for PHP.
You could try to build the image by hand with PHP's image functions http://www.php.net/manual/en/book.image.php
Or you could try executing a external script like: http://marginalhacks.com/Hacks/html2jpg/
I've built an e-shopping website for a big company which has country offices.
What i want to do is the following
Generate barcode via PHP before sending package to country offices of company
When the item will be arrived to country office, workers will login to their account, scan this barcode via barcode reader (which located on package) and website will automatically "approve" that item received.
Is it possible only with web interface? I mean without any local application. How to do that? PLease explain.
so here is an approach that could work for you:
You need to put a record in a database like:
package_id | name | status
1234 My Package shipped
Generate a barcode which contains the package_id, you have to decide what kind of barcode you want to use. You could also use a data matrix. Then you create the bar code as image so that you can print it. Data Matrix is very good for large custom data.
A jQuery Barcode Generator: http://barcode-coder.com/en/barcode-online-generator-2.html
Print the bar code, put it on your package
The package arrives at the office, the user logs on to your website, clicks on "Confirm Package Received" or whatever. Then there is a text-field, he focuses the text-field, scans the barcode/data matrix and your package ID "1234" will appear in the text-field
Submit the form, lookup the entry in the database, change it to:
package_id | name | status
1234 My Package delivered
A Tip If you use a QR Code it can be read by many mobile phones, so you don't need a real bar code scanner. You could write an app that reads the bar code and sends the package_id to your server.
Tcpdf has a few classes for generating barcodes:
http://www.tcpdf.org/doc/code/classTCPDFBarcode.html
With good examples:
http://www.tcpdf.org/examples.php
For example the first:
// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');
// output the barcode as HTML object
echo $barcodeobj->getBarcodeHTML(2, 30, 'black');
Check larsjung.de/qrcode/
It's JQuery Pluggin, but works well with PHP.
As I see your scenario, you need more than just 1D Barcode. You need QR Code.
Hope this helps.
First, you need to chose which barcode type you want to generate.
There are multiple to consider, 1D or 2D. 1D barcodes are simple encode only a small amount of data.
2D barcodes are bigger and can encode more data, they are also a little more aesthetic :)
If you go for a 2D barcodes, I would recommend QRCode, or DataMatrix. The PDF417 is a viable option if you need to lay your data more horizontally instead of squared.
You can find more information here: http://www.barcodebakery.com/en/resources/guide/php/choosing-barcodes
Once you found your code to write, you consider which reader to get. I currently own a Metrologic Focus FirstFlash MS1690. It reads all the barcodes mentioned above. They are multiple options here again, the easiest is to get a USB barcode reader: when you scan a barcode, it would simply write it to the screen as someone were typing it on the keyboard.
I'm not sure if I completely understand your question, but if you are looking make a file that can be printed as a barcode, you'll need to know what kind of files your barcode printer can print.
And if you are looking to read a barcode with a scanner into a webform, the scanner needs to recognize the barcode type. The scanner inputs the barcode value into the webform (or any other program that accepts text). The webform has nothing to do with recognizing a barcode.
I'm looking at Zend barcode to do something similar, but admittedly I'm only getting started. I'm eager to know how others handle this.
This is possible to make using php only. For this you need to take any ready php class to generate qr-code or barcode. Generating barcode may be performed with means of just selecting appropriate bacode font, so, instead of writting numbers php will be writing by barcoded digits. Reading of barcode was described above.
Important note about TCPDF library:
A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable.
For generating linear and bidimensional barcodes there is separate library:
https://github.com/tecnickcom/tc-lib-barcode
To generate barcode using the tc-lib-barcode library:
$bobj = $barcode->getBarcodeObj('CODABAR', '123456', -3, -30, 'black', array(0, 0, 0, 0));
// output the barcode as HTML div (see other output formats in the documentation and examples)
echo $bobj->getHtmlDiv();
echo "</br>";
//Output as png image
echo "<p><img alt=\"Embedded Image\" src=\"data:image/png;base64,".base64_encode($bobj->getPngData())."\" /></p>";
//Save image to folder
$destination_folder = "uploads/barcode.png";
file_put_contents($destination_folder, $bobj->getPngData());
Note:- I have used 'CODABAR' as barcode type. You can change the type of barcode/QR-code according to your needs.