Skip to main content

DocutainSDKPlugin

Main class of the Docutain SDK.

Methods

initSDK()

initSDK(args): Promise<void>

Initializes the Docutain SDK. This method needs to be called prior to using any functionality of the Docutain SDK.

Parameters

ParameterTypeDescription
argsobject
args.licenseKeystringyour Docutain SDK license key.

Returns

Promise\<void>


scanDocument()

scanDocument(args): Promise<object>

Starts the document scanner.

Parameters

ParameterTypeDescription
argsobject
args.configDocumentScannerConfigurationan instance of DocumentScannerConfiguration.

Returns

Promise\<object>

status
status: string;

loadFile()

loadFile(args): Promise<void>

Parameters

ParameterType
argsobject
args.filepathstring

Returns

Promise\<void>


getText()

getText(): Promise<object>

Detects the text of the currently loaded document and returns it.

Returns

Promise\<object>

text
text: string;

getTextPage()

getTextPage(args): Promise<object>

Detects the text of the currently loaded document and returns it.

Parameters

ParameterTypeDescription
argsobject
args.pageNumbernumbernumber of the page you want the text from or leave empty to get text of entire document

Returns

Promise\<object>

text
text: string;

setAnalyzeConfiguration()

setAnalyzeConfiguration(args): Promise<void>

This method sets the analyze configuration.

Parameters

ParameterTypeDescription
argsobject
args.configAnalyzeConfigurationAn instance of AnalyzeConfiguration.

Returns

Promise\<void>


analyze()

analyze(): Promise<object>

Analyzes the currently loaded document and returns the detected data.

Returns

Promise\<object>

data
data: string;

writePDF()

writePDF(args): Promise<object>

This method generates a PDF document from the loaded or scanned pages.

Parameters

ParameterTypeDescription
argsobject
args.fileUristringthe file path where to save the PDF document.
args.overWritebooleanif file already exist, indicate whether to override it or to append number, e.g. TestPDF(1).pdf.
args.pageFormatPDFPageFormatthe PDF page format, refer to PDFPageFormat.
args.maxSizeKB?numberthe maximum file size in KB of the PDF or 0 if no compression should be applied. E.g. if you want a max of 10MB, set it to 10 * 1024. 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\<object>

the file path if PDF document was generated successfully, null otherwise.

fileUri
fileUri: string;

setLogLevel()

setLogLevel(args): Promise<void>

This method sets the log level, which determines the severity of the message.

Parameters

ParameterTypeDescription
argsobject
args.logLevelLogLevelThe Level determining which kind of messages should be logged. The default is Level.Verbose.

Returns

Promise\<void>


getTraceFile()

getTraceFile(): Promise<object>

This method returns the Trace file which includes logging and error messages.

Returns

Promise\<object>

fileUri
fileUri: string;

deleteTempFiles()

deleteTempFiles(args): Promise<void>

This method deletes all temporary files created by the Docutain SDK.

Parameters

ParameterTypeDescription
argsobject
args.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\<void>


writeImage()

writeImage(args): Promise<object>

This method generates a JPG from the loaded or scanned page and saves it to a local file.

Parameters

ParameterTypeDescription
argsobject
args.pageNumbernumberthe page to be generated as JPG
args.fileUristringthe file uri where to save the JPG file

Returns

Promise\<object>

fileUri
fileUri: string;

getImageBytes()

getImageBytes(args): Promise<object>

This method generates a JPG from the loaded or scanned page and returns it as a base64 encoded string.

Parameters

ParameterTypeDescription
argsobject
args.pageNumbernumberthe page to be generated as JPG
args.pageSourceTypePageSourceTypethe PageSourceType type to be used when generating the JPG

Returns

Promise\<object>

bytes
bytes: string;

pageCount()

pageCount(): Promise<object>

This method returns the page count of the currently loaded document.

Returns

Promise\<object>

count
count: number;