documentCapture.documentToText.promise(options)
The content in this help topic pertains to SuiteScript 2.1.
|
Method Description |
Asynchronously extracts text content from a PDF file. This method returns the text of the specified PDF file located in the NetSuite File Cabinet. If you want to extract other content from a file, such as tables and fields (key-value pairs), or extract content from a JPG, PNG, or TIFF file, use documentCapture.documentToStructure(options) instead. Encrypted files are not supported. You can use the text returned from this method in calls to N/llm methods for further querying. For example, you can provide the returned text to llm.generateText(options) and ask questions about the data, as the following code sample shows:
This method doesn't consume usage from the monthly usage pool of free requests provided by NetSuite (unlike documentCapture.documentToStructure(options), which does consume usage).
Note:
The parameters and errors thrown for this method are the same as those for documentCapture.documentToText(options). For more information about promises, see Promise Object. |
|
Returns |
|
|
Synchronous Version |
|
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
|
Governance |
100 |
|
Module |
|
|
Since |
2025.2 |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/documentCapture Module Script Samples.
// Add additional code
...
// "14" is the unique ID of a PDF stored in the NetSuite File Cabinet
const fileObj = file.load({
id: "14"
});
documentCapture.documentToText.promise({
file: fileObj,
timeout: 40000
}).then(function(result) {
// Work with the result
});
...
// Add additional code