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-beta2 --scope <scope> projects locations-documents-process ...

Required Scalar Argument

  • <parent> (string)
    • Target project and location to make a call. Format: projects/{project-id}/locations/{location-id}. If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method.

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:

GoogleCloudDocumentaiV1beta2ProcessDocumentRequest:
  automl-params:
    model: string
  document-type: string
  entity-extraction-params:
    enabled: boolean
    model-version: string
  form-extraction-params:
    enabled: boolean
    model-version: string
  input-config:
    contents: string
    gcs-source:
      uri: string
    mime-type: string
  ocr-params:
    language-hints: [string]
  output-config:
    gcs-destination:
      uri: string
    pages-per-shard: integer
  parent: string
  table-extraction-params:
    enabled: boolean
    header-hints: [string]
    model-version: string

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 .automl-params model=ipsum

    • Resource name of the AutoML model. Format: projects/{project-id}/locations/{location-id}/models/{model-id}.
  • .. document-type=invidunt

    • Specifies a known document type for deeper structure detection. Valid values are currently "general" and "invoice". If not provided, "general"\ is used as default. If any other value is given, the request is rejected.
  • entity-extraction-params enabled=true
    • Whether to enable entity extraction.
  • model-version=duo

    • Model version of the entity extraction. Default is "builtin/stable". Specify "builtin/latest" for the latest model.
  • ..form-extraction-params enabled=true

    • Whether to enable form extraction.
  • model-version=sed

    • Model version of the form extraction system. Default is "builtin/stable". Specify "builtin/latest" for the latest model. For custom form models, specify: "custom/{model_name}". Model name format is "bucket_name/path/to/modeldir" corresponding to "gs://bucket_name/path/to/modeldir" where annotated examples are stored.
  • ..input-config contents=ut

    • Content in bytes, represented as a stream of bytes. Note: As with all bytes fields, proto buffer messages use a pure binary representation, whereas JSON representations use base64. This field only works for synchronous ProcessDocument method.
  • gcs-source uri=gubergren

    • No description provided.
  • .. mime-type=rebum.

    • Required. Mimetype of the input. Current supported mimetypes are application/pdf, image/tiff, and image/gif. In addition, application/json type is supported for requests with ProcessDocumentRequest.automl_params field set. The JSON file needs to be in Document format.
  • ..ocr-params language-hints=est

    • List of languages to use for OCR. In most cases, an empty value yields the best results since it enables automatic language detection. For languages based on the Latin alphabet, setting language_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). Document processing returns an error if one or more of the specified languages is not one of the supported languages.
    • Each invocation of this argument appends the given value to the array.
  • ..output-config.gcs-destination uri=ipsum

    • No description provided.
  • .. pages-per-shard=51

    • The max number of pages to include into each output Document shard JSON on Google Cloud Storage. The valid range is [1, 100]. If not specified, the default value is 20. For example, for one pdf file with 100 pages, 100 parsed pages will be produced. If pages_per_shard = 20, then 5 Document shard JSON files each containing 20 parsed pages will be written under the prefix OutputConfig.gcs_destination.uri and suffix pages-x-to-y.json where x and y are 1-indexed page numbers. Example GCS outputs with 157 pages and pages_per_shard = 50: pages-001-to-050.json pages-051-to-100.json pages-101-to-150.json pages-151-to-157.json
  • .. parent=est

    • Target project and location to make a call. Format: projects/{project-id}/locations/{location-id}. If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method.
  • table-extraction-params enabled=true
    • Whether to enable table extraction.
  • header-hints=ea
    • Optional. Reserved for future use.
    • Each invocation of this argument appends the given value to the array.
  • model-version=dolor
    • Model version of the table extraction system. Default is "builtin/stable". Specify "builtin/latest" for the latest model.

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.

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").