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<boolean>
Starts the document scanner.
Parameters
Parameter | Type | Description |
---|---|---|
options | DocumentScannerConfiguration | an instance of |
Returns
Promise
\<boolean
>
true if user finished scan process successfully, false if user canceled the scan process.
See
loadFile()
loadFile(filePath): Promise<boolean>
Loads a file from the given path.
Parameters
Parameter | Type | Description |
---|---|---|
filePath | string | the 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
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 |
---|---|
config | 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
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. |
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.