MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / getText

Function getText

document-ai/process-document-form.js:113–123  ·  view source on GitHub ↗
(textAnchor, text)

Source from the content-addressed store, hash-verified

111
112 // Extract shards from the text field
113 const getText = (textAnchor, text) => {
114 if (!textAnchor.textSegments || textAnchor.textSegments.length === 0) {
115 return '';
116 }
117
118 // First shard in document doesn't have startIndex property
119 const startIndex = textAnchor.textSegments[0].startIndex || 0;
120 const endIndex = textAnchor.textSegments[0].endIndex;
121
122 return text.substring(startIndex, endIndex);
123 };
124
125 // [END documentai_process_form_document]
126 await processDocument();

Callers 2

processDocumentFunction · 0.70
printTableInfoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected