Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@thegrizzlylabs/cordova-plugin-genius-scan
Advanced tools
This Cordova plugin allows you to access the Genius Scan SDK core features from a Cordova application:
This plugin is based on the Genius Scan SDK for which you need to setup a license. You can aleady try the "demo" version for free by not setting a license key, the only limitation being that the app will exit after 60 seconds.
To buy a license:
You can learn more about licensing in our website and contact us at sdk@geniusscan.com for further questions.
As an example, you can check our demo application
This plugin requires cordova-cli
above 7.0.0: see this page for upgrading if you have an older version.
cordova-ios
above 4.3.0
Nothing to do on a new project; use cordova platform update ios --save
within your existing cordova project to upgrade it.cordova-android
at least 6.x.xNote for Xcode 10 users: Cordova-ios is not fully compatible with Xcode 10 yet, you may need to use cordova run ios --buildFlag="-UseModernBuildSystem=0"
command to build the project properly
If you are using an older plugin version, you will first need to remove the plugin from your cordova project:
cordova plugin remove @thegrizzlylabs/cordova-plugin-genius-scan
Then you can install the new version following the instructions below.
You can install the plugin with Cordova CLI, plugman, or using the config.yml
file.
Note for Phonegap, Ionic and other cordova-based tools:
You can usually run cordova commands from the phonegap
/ionic
cli.
ionic cordova prepare
ionic cordova plugin add ....
phonegap cordova prepare
(or, shorter phonegap prepare
)From your Cordova project folder, install the plugin with the following command:
cordova plugin add @thegrizzlylabs/cordova-plugin-genius-scan
Add the following lines to your project's config.yml file:
<plugin name="@thegrizzlylabs/cordova-plugin-genius-scan" spec="~3.0.5">
<variable name="CAMERA_USAGE_DESCRIPTION" value="Add your message here" />
</plugin>
And run cordova prepare
.
From your Cordova project folder, you can also use plugman to install the plugin only for a specific platform.
plugman install --platform ios --project ./platforms/ios --plugin @thegrizzlylabs/cordova-plugin-genius-scan
Once the deviceReady
Cordova event has been fired, the following methods will be available:
Initialize the SDK with a valid license key:
cordova.plugins.GeniusScan.setLicenseKey(licenseKey, /* autoRefresh = */ true)
setLicenseKey
doesn't return anything. However, other methods of the plugin will fail if the license key is invalid or expired. Note that, for testing purpose, you can also use the plugin without setting a license key, but it will only work for 60 seconds.
It is recommended to show a message to users asking them to update the application in case the license has expired.
cordova.plugins.GeniusScan.scanWithConfiguration(configuration, onSuccess, onFail)
The method scanWithConfiguration
takes a configuration
parameter which can take the following options:
source
: camera
, image
or library
(defaults to camera)sourceImageUrl
: an absolute image url, required if source
is image
. Example: file:///var/…/image.png
multiPage
: boolean (defaults to true). If true, after a page is scanned, a prompt to scan another page will be displayed. If false, a single page will be scanned.multiPageFormat
: pdf
, tiff
, none
(defaults to pdf
)defaultFilter
: the filter that will be applied by default to enhance scans, or none
if no enhancement should be performed by default. Possible values are listed in the Available filters section. Default value is automatic
.availableFilters
: an array of filters that the user can select when they tap on the edit filter button. Defaults to [none
, automatic
, automaticMonochrome
, automaticBlackAndWhite
, automaticColor
, photo
].pdfPageSize
: fit
, a4
, letter
, defaults to fit.pdfMaxScanDimension
: max dimension in pixels when images are scaled before PDF generation, for example 2000 to fit both height and width within 2000px. Defaults to 0, which means no scaling is performed.pdfFontFileUrl
: Custom font file used during the PDF generation to embed an invisible text layer. If null, a default font is used, which only supports Latin languages.jpegQuality
: JPEG quality used to compress captured images. Between 0 and 100, 100 being the best quality. Default is 60.postProcessingActions
: an array with the desired actions to display during the post processing screen (defaults to all actions). Possible actions are rotate
, editFilter
and correctDistortion
.defaultCurvatureCorrection
: enabled
or disabled
whether a curvature correction should be applied by default (Android only). Disabled by default.photoLibraryButtonHidden
: boolean specifying whether the button allowing the user to pick an image on the Camera screen should be hidden (default to false).flashButtonHidden
: boolean (default to false)defaultFlashMode
: auto
, on
, off
(default to off
)foregroundColor
: string representing a color, must start with a #
. The color of the icons, text (defaults to '#ffffff').backgroundColor
: string representing a color, must start with a #
. The color of the toolbar, screen background (defaults to black)highlightColor
: string representing a color, must start with a #
. The color of the image overlays (default to blue)menuColor
: string representing a color, must start with a #
. The color of the menus (defaults to system defaults.)ocrConfiguration
: text recognition options. Text recognition will run on a background thread for every captured image. No text recognition will be applied if this parameter is not present.
languages
: list of BCP 47 language tags (eg ["en-US"]
) for which to run text recognition. Note that text recognition will take longer if multiple languages are specified.outputFormats
: an array with the formats in which the OCR result is made available in the ScanFlow result (defaults to all formats). Possible formats are rawText
, hOCR
and textLayerInPDF
.structuredData
: an array of the structured data you want to extract. E.g.: ['receipt', 'businessCard']
. Possible values are bankDetails
, receipt
, businessCard
. Only available on iOS.It returns a promise with result
object containing:
multiPageDocumentUrl
: a document containing all the scanned pages (example: "file://.pdf")scans
: an array of scan objects. Each scan object has:
originalUrl
: the original file as scanned from the camera. "file://.jpeg"enhancedUrl
: the cropped and enhanced file, as processed by the SDK. "file://.{jpeg|png}"ocrResult
: the result of text recognition for this scan
text
: the raw text that was recognizedhocrTextLayout
: the recognized text in hOCR format (with position, style…)structuredData
: the result of the structured data extraction. A subdictionary will be present for each type of structured data detected by the scan flow.The ScanFlow offers a variety of filters to enhance the appearance of different kinds of documents.
Some filters are dynamic (or automatic), meaning they will apply the best enhancement possible, possibly with some constraints. For example, the automaticBlackAndWhite
filter will apply the best enhancement, assuming that the scan is a text document and making sure the output will have a grayscale color palette.
Here is a list of all possible dynamic filters: automatic
, automaticColor
, automaticBlackAndWhite
, automaticMonochrome
.
Other filters are static filters, which means they always perform the same enhancement operation, without any logic on the document characteristics.
The different static filters are: photo
, softBlackAndWhite
, softColor
, strongMonochrome
, strongBlackAndWhite
, strongColor
, darkBackground
.
In case of failure, error callback function is called with an error message as a string
If you'd like to rearrange the pages returned by the ScanFlow or add some more pages, you can do so and generate a PDF document from these pages:
cordova.plugins.GeniusScan.generateDocument(document, configuration, onSuccess, onFail)
The document
parameter is a map containing the following values:
pages
: an array of page objects. Each page object has:
imageUrl
: the URL of the image file for this page, e.g. file://<filepath>.{jpeg|png}
hocrTextLayout
: the text layout in hOCR formatThe configuration
parameter provides the following options:
outputFileUrl
: the URL where the document should be generated, e.g. file://<filepath>.pdf
pdfFontFileUrl
: Custom font file used during the PDF generation to embed an invisible text layer. If null, a default font is used, which only supports Latin languages.You can use this plugin with any Cordova-based framework, for example Ionic. The way to detect that the device is ready is slightly different, but after that you also access the plugin with cordova.plugins.GeniusScan.scanWithConfiguration(configuration, onSuccess, onFail)
In the controller where you need the plugin, you will have to import Platform
and pass it to the constructor, and also declare the cordova
variable so that TypeScript recognizes it.
import { Platform } from 'ionic-angular';
declare var cordova:any;
export class HomePage {
constructor(private platform: Platform) {
platform.ready().then(() => {
// platform.ready is the equivalent of the deviceReady event described above
// the plugin method is now available:
cordova.plugins.GeniusScan.scanWithConfiguration(...)
});
}
}
The device's locale determines the languages used by the plugin for all strings: user guidance, menus, dialogs…
The plugin supports a wide variety of languages: English (default), Arabic, Chinese (Simplified), Chinese (Traditional), Danish, Dutch, French, German, Hebrew, Indonesian, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish, Turkish, Vietnamese.
NB: iOS applications must be localized in XCode by adding each language to the project.
Make sure that the license key is correct, that is has not expired, and that it is used with the App ID it was generated for. To learn more about the procurement and replacement of license keys, refer to the Licensing FAQ.
See changelog
FAQs
Cordova Plugin for Genius Scan SDK
The npm package @thegrizzlylabs/cordova-plugin-genius-scan receives a total of 654 weekly downloads. As such, @thegrizzlylabs/cordova-plugin-genius-scan popularity was classified as not popular.
We found that @thegrizzlylabs/cordova-plugin-genius-scan demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.