dai_sync: OCR document synchronously

Description Usage Arguments Details Value Examples

View source: R/send_to_dai.R

Description

Sends a single document to the Google Cloud Services (GCS) Document AI v1 API for synchronous (immediate) processing. Returns a HTTP response object containing the OCRed text and additional data.

Usage

1
2
3
4
5
6
7
8
dai_sync(
  file,
  proj_id = get_project_id(),
  proc_id = Sys.getenv("DAI_PROCESSOR_ID"),
  skip_rev = "true",
  loc = "eu",
  token = dai_token()
)

Arguments

file

path to a single-page pdf or image file

proj_id

a GCS project id.

proc_id

a Document AI processor id

skip_rev

whether to skip human review; "true" or "false".

loc

a two-letter region code; "eu" or "us".

token

an authentication token generated by dai_auth() or another auth function.

Details

Requires a GCS access token and some configuration of the .Renviron file; see package vignettes for details.Input files can be in either .pdf, .bmp, .gif, .jpeg, .jpg, .png, or .tiff format. PDF files can be up to five pages long. Extract the text from the response object with text_from_dai_response(). Inspect the entire response object with httr::content().

Value

a HTTP response object

Examples

1
2
3
4
5
6
7
## Not run: 
response <- dai_sync("doc_page.pdf")

my_page_scan <- "001.png"
response <- dai_sync(my_page_scan)

## End(Not run)

daiR documentation built on June 11, 2021, 5:16 p.m.