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): Promise<boolean>

Loads a file from the given path.

Parameters​

ParameterTypeDescription
filePathstringthe path pointing to the file to be loaded.

Returns​

Promise\<boolean>

true if load was succesful, false otherwise.


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): 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.
overWritebooleanif file already exist, indicate whether to override it or to append number, e.g. TestPDF(1).pdf.
PDF_PageFormatPDFPageFormatthe PDF page format, refer to PDFPageFormat.

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
pageSourceTypePageSourceTypethe 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[]>