Skip to main content

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​

ParameterTypeDescription
licenseKeystringyour 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​

ParameterTypeDescription
optionsDocumentScannerConfigurationan instance of

Returns​

Promise\<void>

See​

DocumentScannerConfiguration.


loadFile()​

loadFile(filePath, password?): Promise<boolean>

Loads a file from the given path.

Parameters​

ParameterTypeDescription
filePathstringthe path pointing to the file to be loaded.
password?stringthe 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​

ParameterTypeDescription
bytesstringthe ByteArray of the file to be loaded, base64 encoded.
fileExtensionstringthe extension of the file to be loaded, e.g.
password?stringthe 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​

ParameterTypeDescription
filePathstringthe 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​

ParameterTypeDescription
bytesstringthe ByteArray of the file to be loaded, base64 encoded.
fileExtensionstringthe 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​

ParameterTypeDescription
pageNumberInt32number 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​

ParameterTypeDescription
configAnalyzeConfigurationAn 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​

ParameterTypeDescription
filePathstringthe file path where to save the PDF document.
overWrite?booleanif file already exist, indicate whether to override it or to append number, e.g. TestPDF(1).pdf.
PDF_PageFormat?PDFPageFormatthe PDF page format, refer to PDFPageFormat.
maxSizeKB?numberthe 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​

ParameterTypeDescription
logLevelLogLevelThe 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​

ParameterTypeDescription
deleteTraceFileContentbooleanIf 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​

ParameterTypeDescription
pageNumberInt32the page to be generated as JPG
filePathstringthe 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​

ParameterTypeDescription
pageNumberInt32the page to be generated as JPG
pageSourceType?PageSourceTypethe 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​

ParameterTypeDescription
onboardingbooleanOpens onboarding on next start
scanHintPopupbooleanOpens 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​

ParameterTypeDescription
configPhotoPaymentConfigurationan 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[]>