documentCapture.documentToText.promise(options)

Note:

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:

                    // "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
}).then(function(result) {
    const response = llm.generateText({
        prompt: "What is this invoice for?",
        documents: [{
            id: '14',
            data: result
        }]
    })
}); 

                  

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

Promise Object

Synchronous Version

documentCapture.documentToText(options)

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

100

Module

N/documentCapture Module

Since

2025.2

Syntax

Important:

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 

          

Related Topics

General Notices