The Cropus SDK is used to capture and crop the signature. This SDK is useful to add signature to any digitally created documents.
You can find the release history at Changelog
‼ ATTENTION ‼ → BREAKING CHANGE introduced at Octus SDK v1.4.9
. We have introduced a new license format. If you are using versions prior to v1.4.9
and intend to update to v1.4.9
or above please contact [email protected]
for an updated license.
You will need a valid license and Netrc credentials to use the Cropus SDK, which can be obtained by contacting [email protected].
Once you have the license , follow the below instructions for a successful integration of Cropus SDK onto your iOS Application.
- Xcode 13.0
- iOS 13.0+
- Swift 5.0
In Info.plist file add following code to allow your application to access iPhone's camera:
<key>NSCameraUsageDescription</key> <string>Allow access to camera</string>
You can use CocoaPods to install cropus
by adding it to your Podfile
:
source 'https://gitlab.com/frslabs-public/ios/cropus-ios.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'
target '<Your Target Name>' do
use_frameworks!
pod 'Cropus', '1.6.4'
end
You will need a valid netrc credentials to install cropus from maven, which can be obtained by contacting [email protected]
.
- Create or edit .netrc file under current user's home directory
- Write the below lines into that file, replace <YOUR_USERNAME> and <YOUR_PASSWORD> with your credentials which is shared through email and save the file.
machine www.repo2.frslabs.space
login <YOUR_USERNAME>
password <YOUR_PASSOWRD>
-
In terminal enter below command to install the pod
pod install or pod update or pod install --repo-update.
-
Connect with physical device to build and run Cropus, It will not build/run in simulator due to camera dependency.
To get the full benefits import Cropus
wherever you import UIKit
import UIKit
import Cropus
- Initialize the input parameters and import delegate CropusControllerDelegate
class YourViewController: UIViewController,CropusControllerDelegate {
func cropusScanner(_ scanner: CropusScannerController, didFinishScanningWithResults results: cropusScannerResults) {
if (results.getHighResolutionPath) != nil && (results.getLowResolutionPath) != nil{
let highResolutionImage = getImageFromDocumentDirectory(resultString: results.getHighResolutionPath!)
let lowResolutionImage = getImageFromDocumentDirectory(resultString: results.getLowResolutionPath!)
}else if (results.getHighResolutionPath) != nil {
let highResolutionImage = getImageFromDocumentDirectory(resultString: results.getHighResolutionPath!)
}else if (results.getLowResolutionPath) != nil{
let lowResolutionImage = getImageFromDocumentDirectory(resultString: results.getLowResolutionPath!)
}
scanner.dismiss(animated: true)
}
func cropusScanner(_ scanner: CropusScannerController, didFailWithError error: String) {
print(error)
scanner.dismiss(animated: true)
}
func getImageFromDocumentDirectory(resultString : String) -> UIImage {
var croppedImage = UIImage()
let fileManager = FileManager.default
let fileArray = resultString.components(separatedBy: "/")
let finalFileName = fileArray.last
let path = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent(finalFileName!)
if fileManager.fileExists(atPath: path) {
croppedImage = UIImage(contentsOfFile: path)!
} else {
print("No Image")
}
return croppedImage
}
}
- Invoke Cropus SDK
// ...
override func viewDidLoad(_ animated: Bool) {
let scanner = CropusScannerController(showInstruction: true, delegate:self)
scanner.modalPresentationStyle = .fullScreen
scanner.licenceKey = "CROPUS_LICENCE_KEY"
scanner.setLowResMaxImageSize = 15 // Set low resolution image max size (Minimum size should be 5KB)
scanner.setOutputImageFormat = "jpg" //Output image format either "jpg" or "png" by default result will be in png format.
scanner.setCropusImageSize = CropusImageSize(width:<WIDTH>,height:<HEIGHT>) //Set output image dimension (Minimum size should be 50*50)
scanner.setOutputImageResolution = "BOTH" // Output image resolution either "BOTH","LOW","HIGH" by default result is in "HIGH" resolution image.
self.present(scanner, animated: true)
}
// ...
High Resolution image Output: getImageFromDocumentDirectory(resultString: results.getHighResolutionPath!) //High resolution Output if selected in input side
Low Resolution image Output: getImageFromDocumentDirectory(resultString: results.getLowResolutionPath!) // Low resolution Output if selected in input side
Both Resolution : getImageFromDocumentDirectory(resultString: results.getHighResolutionPath!) & getImageFromDocumentDirectory(resultString: results.getLowResolutionPath!)
Following error codes will be returned on the onCropusFailure
method of the callback
CODE | DESCRIPTION |
---|---|
803 | Camera permission denied |
804 | Cropus interrupted |
805 | Cropus SDK License has expired |
806 | Cropus SDK License is invalid |
807 | Invalid input parameters passed |
809 | Unable to save the cropped image |
810 | Transaction failed/ Ping failed |
Sets the Cropus SDK apiCredentials . Obtain the appropriate api credentials through a REST API call , for details about the REST API, contact [email protected]
For any queries/feedback , contact us at [email protected]