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
Parameter | Type | Description |
---|---|---|
args | object | |
args.licenseKey | string | your Docutain SDK license key. |
Returns
Promise
\<void
>
scanDocument()
scanDocument(args): Promise<object>
Starts the document scanner.
Parameters
Parameter | Type | Description |
---|---|---|
args | object | |
args.config | DocumentScannerConfiguration | an instance of DocumentScannerConfiguration. |
Returns
Promise
\<object
>
status
status: string;
loadFile()
loadFile(args): Promise<void>
Parameters
Parameter | Type |
---|---|
args | object |
args.filepath | string |
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
Parameter | Type | Description |
---|---|---|
args | object | |
args.pageNumber | number | number 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
Parameter | Type | Description |
---|---|---|
args | object | |
args.config | AnalyzeConfiguration | An 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
Parameter | Type | Description |
---|---|---|
args | object | |
args.fileUri | string | the file path where to save the PDF document. |
args.overWrite | boolean | if file already exist, indicate whether to override it or to append number, e.g. TestPDF(1).pdf. |
args.pageFormat | PDFPageFormat | the PDF page format, refer to PDFPageFormat. |
args.maxSizeKB ? | number | the 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
Parameter | Type | Description |
---|---|---|
args | object | |
args.logLevel | LogLevel | The 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
Parameter | Type | Description |
---|---|---|
args | object | |
args.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
\<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
Parameter | Type | Description |
---|---|---|
args | object | |
args.pageNumber | number | the page to be generated as JPG |
args.fileUri | string | the 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
Parameter | Type | Description |
---|---|---|
args | object | |
args.pageNumber | number | the page to be generated as JPG |
args.pageSourceType | PageSourceType | the 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;