I am passing a PDF to the form parser processor (most recent stable release) in an apps script. No matter what I do, I cannot seem to enable the imageless option to permit synchronous processing of PDFs of length 16-30 pages. I get a server error 500 with the message:
"This processor version only supports up to 15 pages per document shard. If using the UI or sync pre..."
Below is my code. I am a novice at this, so it is entirely possible that I have a fundamental misunderstanding of how this should work.
function callDocumentAI(file, imageless = false) {
const token = ScriptApp.getOAuthToken();
const url = `https://${PROJECT_LOCATION}-documentai.googleapis.com/v1/projects/${PROJECT_ID}` +
`/locations/${PROJECT_LOCATION}/processors/${FORM_PARSER_PROCESSOR_ID}:process`;
const inlineDoc = {
content: Utilities.base64Encode(file.getBlob().getBytes()),
mimeType: 'application/pdf'
};
// Build request body
const body = { inlineDocument: inlineDoc };
if (imageless) {
// Enable imageless mode flag
body.imageless_mode = true;
}
// Prepare HTTP options
const options = {
method: 'post',
contentType: 'application/json',
headers: { Authorization: `Bearer ${token}` },
payload: JSON.stringify(body)
};
const resp = UrlFetchApp.fetch(url, options);
return JSON.parse(resp.getContentText());
}
Thank you in advance for any insight you might have.