Getting data from a Barcode Scanner using PHP - php

I've read a couple of posts here on the site and as far as I understand it, using PHP to get and process the information obtained through a Barcode Scanner is possible, however I'd like to ask just to make sure, is it recommended? are there any caveats I should be aware of?
EDIT
I don't know the software of the barcode scanner since I haven't had access to it, however I described how it works on the comments down here. the barcode generates a fixed number of characters so I guess I could use a javascript event listener =)

I've noticed a lot of stores use online or LAN POS sites to handle purchases. Typically, the add an item page will set focus to a text field devoted to the product's barcode. When the scanner scans the barcode it's been preconfigured to output the code to wherever the cursor is (in this case, the barcode text field). Most system then have a JavaScript event listener on the field that submits the new item when a barcode is entered (the field reaches a certain length). Of course this is all theory. If you want sample code, please provide more specifics on the scanner and the software it came with.

Related

Matching DOC and PDF content to string in PHP

So my client want to add a feature to their job site whereby a user uploads a PDF or DOC CV/Resume file to a particular job that they are applying for. The system will then create a score whereby it evaluates how appropriate the candidate is for the job that they're applying for. So in the job description, if it says "2 years banking experience", and in the CV/Resume file it says "Barclays Bank - 2 Years", then it adds more to this score for them.
I have advised the client that I do not think that this is the best way to go about things. I feel it would be much better if the job applicant created a profile on the website where they enter this data into the website themselves (similar to LinkedIn) as all data will be appropriately stored.
They are set on the first option and I'm just wondering what the best way of going about this would be? My first thoughts would be to extract the text contents from the document.
What you want cannot be made fully functional, even though data extraction from DOC and PDF files is possible
Although, you can tell you client that the visitor, candidate, can download a Sample CV, fill it, paste it and then upload it; to get particular ratings

Adding a prefix to the value of a QR code via a mobile app

I've built a ticketing system with PHP & MySQL that generates a barcode for each ticket. The current set up for scanning tickets is a simple web form and a USB barcode scanner. When a barcode is scanned, it submits the barcode's ID to the form and if it matches an ID in the database then the ticket is valid.
I'd now like to be able to scan tickets with a mobile device and am wondering which is the best route to go down. How I envisage it working is the the barcode (or QR code) will have a value like "9783546" and when it's scanned, it will point to a URL like http://www.myscanner.com/checkticket.php?id=9783546
(Perhaps this is not the best solution, if not please let me know.)
Another caveat is that I'd rather not hardcode the URL in to the qrcode itself, as it's liable to change.
I know there are QR code libraries for building scanners for iPhone and Android. Is there an advantage of using one over the other? Is pointing to the url like above the best way to handle this? Is there a prebuilt scanner that allows something like this already?
Apologies for the broad question, some points in the right direction would be greatly appreciated.
I was developing simular project. While researching i decided to stop on this library.
It is really easy for integrating with your project and it can handle many different types of barcodes.
You should check this library if it supports types of barcodes(QR codes) you needed.
And here you cand find example of integration zxing with android.
https://github.com/zxing/zxing/tree/master/android-integration/src/main/java/com/google/zxing/integration/android
But it is steel difficult to scan barcode very fast. You should aim on barcode and after 1-2 seconds it will be scanned. If you want to have fast scanner and if you want scanner to be able to scan barcodes at night time you should consider idea of buing additional device for scanning.
For example like this: http://ru.aliexpress.com/item/Mobile-Barcode-Scanner-for-Cell-Phones-of-Android-wp8-Bluetooth-portable-barcode-reader-data-collection-terminal/509789346.html
It can be easyliy integrated with you android devices through Bluetooth.

Barcode generation and decoding in PHP

I need to develop a PHP application that will be generating barcodes and also will have the ability to read those barcodes back.
As my application will be a web based application and underlying technology is PHP which is a server side scripting language, I am feeling that barcode generation will not be an issue but the scanning and reading those barcodes may be a challenge.
Please guide me if its possible to read barcode in a PHP application.
Reading a barcode is usually easy, because barcode readers are usually the same as a normal keyboard, thus writing to the application as if it would be typed by the user. You just need to provide a text field on your page, where the data is entered. The user of course needs a barcode reader.
By adding [Enter] or [Tab] characters to the barcode, you can control to change to the next field or send the form to the server without additional user interaction.
Here is some links for your reference
http://www.ashberg.de/php-barcode/
http://www.phpclasses.org/package/2874-PHP-Recognize-text-objects-in-graphical-images.html
http://www.perkiset.org/forum/php/barcode_generator_using_php_and_gd-t2406.0.html
The trick to understanding bar code generation is to realize that a bar code is just an alternative way of writing characters. Some types of bar code have a limited set of characters they can represent (e.g. UPC is a fixed number (usually 13) of characters in the range 0-9)., others such as Code 3 of 9 have a wider range of characters (e.g. Code 3 of 9 is alpha numeric).
So the easiest way to generate bar codes is to use of one of the free Code 3 of 9 fonts, and use that to generate your bar code. You can either use the font in conjunction with the GD library to generate an image, or if you want to generate a PDF containing a bar code just incorporate the characters written in the bar code font directly into the PDF. You may even be able to get a bar code font from one of the web font services such as TypeKit or Google Web Fonts, and just put the bar code directly into the HTML page.
For reading back the bar codes, there's nothing in a normal web browser which will read a bar code and return just the characters. The user of your web app will need to upload an image containing the bar code which you can process on the server. The links that Miqdad Ali posted in his answer might help you do it server side.

Generating and reading barcode

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.

Suggestions for making an offline version of an online form?

I work for a school district in which the teachers submit their lesson plans to their principals online.
They do this using an online form I wrote using PHP/MySQL and it uses TinyMCE for its textareas. One of the major features that was requested was for teachers to be able to save their incomplete forms as drafts to submit later. This was implemented, but the new problem I'm facing is that not all teachers have access to the internet at home, thus they cannot work on their lesson plans while at home.
Of course, they could cut and paste out of a word document or text file that they save on their laptops, but then they have to cut/paste one textarea at a time, and they complain about it.
So what I was thinking about trying, is making an offline application that looks like the online form, but saves the form in an xml format on their computer. Then they could open this file to keep working on it, or upload it to the online form later.
My question is: being that my programming experience is currently limited to a few web-related languages (php, javascript, html) what should I use to attempt to write this offline app? Winbinder? Adobe AIR?
I think your best bet will be to ask them to install Google Gears on their browser (comes by default with Google Toolbar iirc), which is ideal for storing content offline. And then as soon as they go online it's easy to sync the stored content back to your online server.
Gears API Documentation can be found here.
How are teachers currently working on their lesson plans offline?
If they're doing it in plain text, for example, perhaps you can simply add a file upload field. They would upload their file (which they worked on offline), and your web app would parse it and divide it up into the appropriate sections.
(If rich text is a requirement, they can use a Word doc.)
To aid with parsing, you could tell them to use section headers -- maybe special words in all caps -- or provide them an example template (which maps directly to the web form) to start from.
The idea here is that you may want to minimize the changes teachers will need to make. They're already used to what they're currently doing, so work with their current habits. It would be easier than having them change and do something new. Installing a new offline app on their computers is almost certainly a significant barrier.
(While I was typing this answer, Josh Curren submitted a similar one.)
I would save the form to a text file that they can save to their desktop, then upload it and read it into the form later. You would have to supply them with a template so that everything they enter is in the correct order.
One simple option would be to build a regular desktop app they could install locally and take with them. Have an upload function in the app that allows them to submit it when they are connected to the internet.
Another option is to use create an editable PDF of the form, then either a) submit those as a whole to the principal, or b) parse out the field data on the server side.
IF they are using Internet Explorer at BOTH school and home, you could give them the form in a webpage saved in the web archive format, *.mht. They fill out the form at home and save it in the same *.mht format. When they return to school they open the page and submit it.
This should work and may be simple to implement. I tried it on this post, but ran into problems somewhere between the captcha and the openid login. Give it a try on your form.
I've actually gone with Adobe AIR to do this.
With AIR, the form looks nearly identical to the one that's used online and even uses the same TinyMCE library. And I didn't have to learn much to get it going, just the AIR javascript API.
I'm also using AIR to write a few other apps and I love it.

Categories