DocutainSDK
Main class of the Docutain SDK.
Methods
initSDK()
initSDK(licenseKey): Promise<boolean>
Initializes the Docutain SDK. This method needs to be called prior to using any functionality of the Docutain SDK.
Parameters
| Parameter | Type | Description |
|---|---|---|
licenseKey | string | your Docutain SDK license key. |
Returns
Promise\<boolean>
true if initialization was successful, false otherwise. Use getLastError() to retrieve error message.
scanDocument()
scanDocument(options): Promise<void>
Starts the document scanner.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | DocumentScannerConfiguration | an instance of |
Returns
Promise\<void>
See
loadFile()
loadFile(filePath, password?): Promise<boolean>
Loads a file from the given path.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | the path pointing to the file to be loaded. |
password? | string | the password if file is encrypted. |
Returns
Promise\<boolean>
true if load was succesful, false otherwise.
loadFileBytes()
loadFileBytes(
bytes,
fileExtension,
password?): Promise<boolean>
This method loads a file from the given ByteArray.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | string | the ByteArray of the file to be loaded, base64 encoded. |
fileExtension | string | the extension of the file to be loaded, e.g. |
password? | string | the password if file is encrypted. |
Returns
Promise\<boolean>
addPageFile()
addPageFile(filePath): Promise<boolean>
This method adds a page from the given path to the currently loaded document. Only paths in internal app directory and it's subdirectories are supported.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | the path pointing to the file to be loaded. |
Returns
Promise\<boolean>
addPageBytes()
addPageBytes(bytes, fileExtension): Promise<boolean>
This method adds a page from the given ByteArray to the currently loaded document.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | string | the ByteArray of the file to be loaded, base64 encoded. |
fileExtension | string | the extension of the file to be loaded, e.g. |
Returns
Promise\<boolean>
getText()
getText(): Promise<string>
Detects the text of the currently loaded document and returns it.
Returns
Promise\<string>
the detected text
getTextPage()
getTextPage(pageNumber): Promise<string>
Detects the text of the currently loaded document and returns it.
Parameters
| Parameter | Type | Description |
|---|---|---|
pageNumber | Int32 | number of the page you want the text from or leave empty to get text of entire document |
Returns
Promise\<string>
the detected text
setAnalyzeConfiguration()
setAnalyzeConfiguration(config): Promise<boolean>
This method sets the analyze configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | AnalyzeConfiguration | An instance of AnalyzeConfiguration. |
Returns
Promise\<boolean>
true if configuration was successful, false otherwise.
analyze()
analyze(): Promise<string>
Analyzes the currently loaded document and returns the detected data.
Returns
Promise\<string>
the detected data as JSON String
writePDF()
writePDF(
filePath,
overWrite?,
PDF_PageFormat?,
maxSizeKB?): Promise<string>
This method generates a PDF document from the loaded or scanned pages.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | the file path where to save the PDF document. |
overWrite? | boolean | if file already exist, indicate whether to override it or to append number, e.g. TestPDF(1).pdf. |
PDF_PageFormat? | PDFPageFormat | the PDF page format, refer to PDFPageFormat. |
maxSizeKB? | number | the maximum file size in KB of the PDF or 0 if no compression should be applied. The PDF will only be compressed if the uncompressed PDF would exceed the max you have set. Please be aware, that if the PDF gets compressed, the quality decreases and the PDF generation will take longer. |
Returns
Promise\<string>
the file path if PDF document was generated successfully, null otherwise.
getLastError()
getLastError(): Promise<string>
This method returns the latest error message, if any error occurred.
Returns
Promise\<string>
the error message.
setLogLevel()
setLogLevel(logLevel): Promise<boolean>
This method sets the log level, which determines the severity of the message.
Parameters
| Parameter | Type | Description |
|---|---|---|
logLevel | LogLevel | The Level determining which kind of messages should be logged. The default is Level.VERBOSE. |
Returns
Promise\<boolean>
getTraceFile()
getTraceFile(): Promise<string>
This method returns the Trace file which includes logging and error messages.
Returns
Promise\<string>
the path to the Trace file.
deleteTempFiles()
deleteTempFiles(deleteTraceFileContent): Promise<boolean>
This method deletes all temporary files created by the Docutain SDK.
Parameters
| Parameter | Type | Description |
|---|---|---|
deleteTraceFileContent | boolean | If true, the content of the Trace file which you can send us in order to solve any problems will also be deleted |
Returns
Promise\<boolean>
true if all files deleted successfully, false if an error occurred
writeImage()
writeImage(pageNumber, filePath): Promise<string>
This method generates a JPG from the loaded or scanned page and saves it to a local file.
Parameters
| Parameter | Type | Description |
|---|---|---|
pageNumber | Int32 | the page to be generated as JPG |
filePath | string | the file path where to save the JPG file |
Returns
Promise\<string>
the file path if JPG was generated successfully, null otherwise
getImageBytes()
getImageBytes(pageNumber, pageSourceType?): Promise<string>
This method generates a JPG from the loaded or scanned page and returns it as a base64 encoded string.
Parameters
| Parameter | Type | Description |
|---|---|---|
pageNumber | Int32 | the page to be generated as JPG |
pageSourceType? | PageSourceType | the PageSourceType type to be used when generating the JPG |
Returns
Promise\<string>
the base64 encoded string if JPG was generated successfully, null otherwise
pageCount()
pageCount(): Promise<Int32>
This method returns the page count of the currently loaded document.
Returns
Promise\<Int32>
page count of the currently loaded document.
resetOnboarding()
resetOnboarding(onboarding, scanHintPopup): Promise<void>
Resets onboarding state.
Parameters
| Parameter | Type | Description |
|---|---|---|
onboarding | boolean | Opens onboarding on next start |
scanHintPopup | boolean | Opens scanHintPopup on next start. |
Returns
Promise\<void>
onboardingDefaultItems()
onboardingDefaultItems(): Promise<DocutainListItem[]>
Gets the default onboarding items.
Returns
Promise\<DocutainListItem[]>
scanTipsDefaultItems()
scanTipsDefaultItems(): Promise<DocutainListItem[]>
Gets the default scan tips items.
Returns
Promise\<DocutainListItem[]>
startPhotoPayment()
startPhotoPayment(config): Promise<string>
Starts the photo payment process.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | PhotoPaymentConfiguration | an instance of PhotoPaymentConfiguration. |
Returns
Promise\<string>
emptyResultScreenDefaultItems()
emptyResultScreenDefaultItems(): Promise<DocutainListItem[]>
Gets the default empty result screen items.
Returns
Promise\<DocutainListItem[]>
onboardingDefaultItemsPhotoPayment()
onboardingDefaultItemsPhotoPayment(): Promise<DocutainListItem[]>
Gets the default photo payment onboarding items.
Returns
Promise\<DocutainListItem[]>
scanTipsDefaultItemsPhotoPayment()
scanTipsDefaultItemsPhotoPayment(): Promise<DocutainListItem[]>
Gets the default photo payment scan tips items.
Returns
Promise\<DocutainListItem[]>