Google Document AI
Client and converter for Google Document AI Enterprise OCR.
import {
GoogleDocumentAiOcrOptionsSchema,
GOOGLE_DOCAI_OCR_OUTPUT_CAPABILITIES,
createAwsWorkloadIdentityGoogleAuth,
createGoogleDocumentAiClient,
mapGoogleDocumentAiToParsedDocument,
} from '@openparser/adapters/google-document-ai';Client
const client = createGoogleDocumentAiClient({
projectId: googleConfig.projectId,
location: googleConfig.location,
processorId: googleConfig.processorId,
processorVersionId: googleConfig.processorVersionId,
});
const { canonical } = await client.parse({
bytes: documentBytes,
mediaType: 'application/pdf',
documentId: 'doc-1',
options: { native_pdf_parsing: true, image_quality_scores: true },
});Omit auth to use Application Default Credentials or Workload Identity Federation. For ECS/Fargate WIF, pass explicit auth from credentials your runtime already loaded:
const client = createGoogleDocumentAiClient({
...googleConfig,
auth: createAwsWorkloadIdentityGoogleAuth({
externalAccountJson: wifConfig.externalAccountJson,
region: wifConfig.awsRegion,
ecsCredentialsRelativeUri: wifConfig.ecsCredentialsRelativeUri,
ecsAuthorizationToken: wifConfig.ecsAuthorizationToken,
}),
});Synchronous ProcessDocument for Enterprise OCR accepts at most 15 PDF pages per request (GOOGLE_DOCAI_SYNC_MAX_PDF_PAGES).
Adapter-only
Call mapGoogleDocumentAiToParsedDocument when you already have a Document protobuf JSON payload.