Processes a single document.
Scopes
You will need authorization for the https://www.googleapis.com/auth/cloud-platform scope to make a valid call.
If unset, the scope for this method defaults to https://www.googleapis.com/auth/cloud-platform.
You can set the scope for this method like this: documentai1 --scope <scope> projects locations-processors-processor-versions-process ...
Required Scalar Argument
- <name> (string)
- Required. The resource name of the Processor or ProcessorVersion to use for processing. If a Processor is specified, the server will use its default version. Format:
projects/{project}/locations/{location}/processors/{processor}
, orprojects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}
- Required. The resource name of the Processor or ProcessorVersion to use for processing. If a Processor is specified, the server will use its default version. Format:
Required Request Value
The request value is a data-structure with various fields. Each field may be a simple scalar or another data-structure. In the latter case it is advised to set the field-cursor to the data-structure's field to specify values more concisely.
For example, a structure like this:
GoogleCloudDocumentaiV1ProcessRequest:
field-mask: string
gcs-document:
gcs-uri: string
mime-type: string
inline-document:
content: string
error:
code: integer
message: string
mime-type: string
shard-info:
shard-count: int64
shard-index: string
text-offset: string
text: string
uri: string
labels: { string: string }
process-options:
from-end: integer
from-start: integer
individual-page-selector:
pages: [integer]
ocr-config:
advanced-ocr-options: [string]
compute-style-info: boolean
disable-character-boxes-detection: boolean
enable-image-quality-scores: boolean
enable-native-pdf-parsing: boolean
enable-symbol: boolean
hints:
language-hints: [string]
premium-features:
compute-style-info: boolean
enable-math-ocr: boolean
enable-selection-mark-detection: boolean
schema-override:
description: string
display-name: string
metadata:
document-allow-multiple-labels: boolean
document-splitter: boolean
prefixed-naming-on-properties: boolean
skip-naming-validation: boolean
raw-document:
content: string
display-name: string
mime-type: string
skip-human-review: boolean
can be set completely with the following arguments which are assumed to be executed in the given order. Note how the cursor position is adjusted to the respective structures, allowing simple field names to be used most of the time.
-r . field-mask=lorem
- Specifies which fields to include in the ProcessResponse.document output. Only supports top-level document and pages field, so it must be in the form of
{document_field_name}
orpages.{page_field_name}
.
- Specifies which fields to include in the ProcessResponse.document output. Only supports top-level document and pages field, so it must be in the form of
gcs-document gcs-uri=accusam
- The Cloud Storage object uri.
-
mime-type=amet
- An IANA MIME type (RFC6838) of the content.
-
..inline-document content=erat
- Optional. Inline document content, represented as a stream of bytes. Note: As with all
bytes
fields, protobuffers use a pure binary representation, whereas JSON representations use base64.
- Optional. Inline document content, represented as a stream of bytes. Note: As with all
error code=32
- The status code, which should be an enum value of google.rpc.Code.
-
message=erat
- A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
-
.. mime-type=accusam
- An IANA published media type (MIME type).
shard-info shard-count=-10
- Total number of shards.
shard-index=takimata
- The 0-based index of this shard.
-
text-offset=lorem
- The index of the first character in Document.text in the overall document global text.
-
.. text=et
- Optional. UTF-8 encoded text in reading order from the document.
-
uri=at
- Optional. Currently supports Google Cloud Storage URI of the form
gs://bucket_name/object_name
. Object versioning is not supported. For more information, refer to Google Cloud Storage Request URIs.
- Optional. Currently supports Google Cloud Storage URI of the form
-
.. labels=key=dolor
- Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.
- the value will be associated with the given
key
process-options from-end=79
- Only process certain pages from the end, same as above.
from-start=53
- Only process certain pages from the start. Process all if the document has fewer pages.
-
individual-page-selector pages=20
- Optional. Indices of the pages (starting from 1).
- Each invocation of this argument appends the given value to the array.
-
..ocr-config advanced-ocr-options=sea
- A list of advanced OCR options to further fine-tune OCR behavior. Current valid values are: -
legacy_layout
: a heuristics layout detection algorithm, which serves as an alternative to the current ML-based layout detection algorithm. Customers can choose the best suitable layout algorithm based on their situation. - Each invocation of this argument appends the given value to the array.
- A list of advanced OCR options to further fine-tune OCR behavior. Current valid values are: -
compute-style-info=true
- Turn on font identification model and return font style information. Deprecated, use PremiumFeatures.compute_style_info instead.
disable-character-boxes-detection=true
- Turn off character box detector in OCR engine. Character box detection is enabled by default in OCR 2.0 (and later) processors.
enable-image-quality-scores=false
- Enables intelligent document quality scores after OCR. Can help with diagnosing why OCR responses are of poor quality for a given input. Adds additional latency comparable to regular OCR to the process call.
enable-native-pdf-parsing=false
- Enables special handling for PDFs with existing text information. Results in better text extraction quality in such PDF inputs.
enable-symbol=false
- Includes symbol level OCR information if set to true.
-
hints language-hints=dolores
- List of BCP-47 language codes to use for OCR. In most cases, not specifying it yields the best results since it enables automatic language detection. For languages based on the Latin alphabet, setting hints is not needed. In rare cases, when the language of the text in the image is known, setting a hint will help get better results (although it will be a significant hindrance if the hint is wrong).
- Each invocation of this argument appends the given value to the array.
-
..premium-features compute-style-info=true
- Turn on font identification model and return font style information.
enable-math-ocr=true
- Turn on the model that can extract LaTeX math formulas.
-
enable-selection-mark-detection=true
- Turn on selection mark detector in OCR engine. Only available in OCR 2.0 (and later) processors.
-
...schema-override description=amet.
- Description of the schema.
display-name=ipsum
- Display name to show to users.
metadata document-allow-multiple-labels=true
- If true, on a given page, there can be multiple
document
annotations covering it.
- If true, on a given page, there can be multiple
document-splitter=false
- If true, a
document
entity type can be applied to subdocument (splitting). Otherwise, it can only be applied to the entire document (classification).
- If true, a
prefixed-naming-on-properties=true
- If set, all the nested entities must be prefixed with the parents.
-
skip-naming-validation=true
- If set, we will skip the naming format validation in the schema. So the string values in
DocumentSchema.EntityType.name
andDocumentSchema.EntityType.Property.name
will not be checked.
- If set, we will skip the naming format validation in the schema. So the string values in
-
....raw-document content=at
- Inline document content.
display-name=sit
- The display name of the document, it supports all Unicode characters except the following:
*
,?
,[
,]
,%
,{
,}
,'
,\"
,,
~
,=
and:
are reserved. If not specified, a default ID is generated.
- The display name of the document, it supports all Unicode characters except the following:
-
mime-type=duo
- An IANA MIME type (RFC6838) indicating the nature and format of the content.
-
.. skip-human-review=true
- Whether human review should be skipped for this request. Default to
false
.
- Whether human review should be skipped for this request. Default to
About Cursors
The cursor position is key to comfortably set complex nested structures. The following rules apply:
- The cursor position is always set relative to the current one, unless the field name starts with the
.
character. Fields can be nested such as in-r f.s.o
. - The cursor position is set relative to the top-level structure if it starts with
.
, e.g.-r .s.s
- You can also set nested fields without setting the cursor explicitly. For example, to set a value relative to the current cursor position, you would specify
-r struct.sub_struct=bar
. - You can move the cursor one level up by using
..
. Each additional.
moves it up one additional level. E.g....
would go three levels up.
Optional Output Flags
The method's return value a JSON encoded structure, which will be written to standard output by default.
- -o out
- out specifies the destination to which to write the server's result to.
It will be a JSON-encoded structure.
The destination may be
-
to indicate standard output, or a filepath that is to contain the received bytes. If unset, it defaults to standard output.
- out specifies the destination to which to write the server's result to.
It will be a JSON-encoded structure.
The destination may be
Optional General Properties
The following properties can configure any call, and are not specific to this method.
-
-p $-xgafv=string
- V1 error format.
-
-p access-token=string
- OAuth access token.
-
-p alt=string
- Data format for response.
-
-p callback=string
- JSONP
-
-p fields=string
- Selector specifying which fields to include in a partial response.
-
-p key=string
- API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
-
-p oauth-token=string
- OAuth 2.0 token for the current user.
-
-p pretty-print=boolean
- Returns response with indentations and line breaks.
-
-p quota-user=string
- Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
-
-p upload-type=string
- Legacy upload protocol for media (e.g. "media", "multipart").
-
-p upload-protocol=string
- Upload protocol for media (e.g. "raw", "multipart").