PDF417 SDK wrapper for PhoneGap
This repository contains example wrapper for PDF417 native SDKs (iOS and Android). Not all features of native SDKs are available in PhoneGap wrapper. However, the wrapper is open source, so you can easily add features that you need. For 100% of features and maximum control, consider using native SDKs.
First generate an empty project if needed:
cordova create <path> <package> <name>
The shown instructions are for Cordova, the instructions for PhoneGap are practically the same, except for some slight command line argument differences.
Add the pdf417 plugin to your project:
cd <path_to_your_project>cordova plugin add <pdf417_plugin_path> # or pdf417-cordova if you don't have pdf417-phonegap locally
Add Android platform support to the project:
cordova platform add android
If you want to add iOS as a platform for your application, you will need to install unzip and wget. Currently cordova plugin uses a hook script, that runs before adding ios platform, to download pdf417 framework and bundle from github.
Add iOS plaform support to the project:
cordova platform add ios
Here's a complete example of how to create and build a project for Android and iOS using cordova (you can substitute equivalent commands for phonegap):
# pull the plugin and sample application from Githubgit clone https://github.com/PDF417/pdf417-phonegap.git# initialize and update submodulesgit submodule initgit submodule update# create a empty applicationcordova create testcordovacd testcordova# add the pdf417 plugincordova plugin add ../pdf417-phonegap/Pdf417# add android support to the projectcordova platform add android@7# build the project, the binary will appear in the bin/ foldercordova build android# add ios support to the projectcordova platform add ios# build the projectcordova build ios
In phonegap CLI instead of "platform add" just request a build for the platform using "build android" or "build ios". You will have to do the manual steps described above to be able to do a successfull build.
You can also use provided
initDemoApp.sh script that will generate a demo app that uses the plugin:
To run the script, you'll need BASH environment on Windows (Linux and MacOS use BASH by default).
/*** Scan these barcode types* Available: "PDF417", "USDL", "QR Code", "Code 128", "Code 39", "EAN 13", "EAN 8", "ITF", "UPCA", "UPCE", "Aztec", "Data Matrix"*/var types = "PDF417" "QR Code";/*** Initiate scan with options* NOTE: Some features are unavailable without a license* Obtain your key at*/var options =beep : true // Beep onnoDialog : true // Skip confirm dialog after scanuncertain : false //RecommendedquietZone : false //RecommendedhighRes : false //RecommendedinverseScanning: falsefrontFace : false;// Note that each platform requires its own license key// This license key allows setting overlay views for this application ID: mobi.pdf417.demo// Valid until 2018-06-04var licenseiOs = "sRwAAAEQbW9iaS5wZGY0MTcuZGVtbz/roBZ34ygXMQRMupTjSPXnoj0Mz1jPfk1iRX7f78Ux6a+pfXVyW0HCjPTxl5ocxgXWF66PTrtFUbJFCDUpyznreSWY4akvhvqVFfcTYgVEKjB+UqO6vPD5iIaUCaEYhF4dVmM=";// This license is only valid for package name "mobi.pdf417.demo"var licenseAndroid = "sRwAAAAQbW9iaS5wZGY0MTcuZGVtb2uCzTSwE5Pixw1pJL5UEN7nyXbOdXB61Ysy/sgAYt4SaB0T/g6JvisLn6HtB8LzLDmpFjULMxmB8iLsy3tFdHtMhLWOM6pr0tQmSLGyhrXfe6rVoHAxJtPrFEoCNTk4RjLltQ==";scanButton;
Available barcode types for the scanner are:
- QR Code
- Code 128
- Code 39
- EAN 13
- EAN 8
- Data Matrix
Additionally, USDL parsing is available when types array contains "USDL" string.
The following options are available:
- beep - Boolean - set to true to play beep sound after successful scan
- noDialog - Boolean - set to true to show confirm dialog after successful scan (license required)
- uncertain - Boolean - set to true to scan even barcode not compliant with standards. For example, malformed PDF417 barcodes which were incorrectly encoded. Use only if necessary because it slows down the recognition process
- quietZone - Boolean - set to true to scan barcodes which don't have quiet zone (white area) around it. Use only if necessary because it drastically slows down the recognition process
- highRes - Boolean - set to true if you want to always use highest possible camera resolution (enabled by default for all devices that support at least 720p camera preview frame size)
- inverseScanning - Boolean - set to true if you want to enable scanning of barcodes with inverse intensity values (e.g. white barcode on black background)
- frontFace - Boolean - to use front facing camera. Note that front facing cameras do not have autofocus support, so it will not be possible to scan denser and smaller codes.
All license parameters must be provided (for iOS and Android) even if you do not plan to run the application on both platforms. The licenses that you do not have/use must be set to
How to get started
- Download PDF417.mobi PhoneGap SDK, and try the sample app for iOS or Android.
Sample app is generated with a script
To run iOS demo application open Xcode project Pdf417Demo.xcodeproj
To run Android demo application type
cd PDF417Democordova run android