Sends a single-page document to Google Document AI v1 for synchronous (immediate) processing. Returns a response object containing the text and additional data.

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 Google Cloud Services 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.

Value

a json response object

Details

Requires a Google Cloud access token (google_token) and a certain amount of configuration in RStudio; see vignettes for details. Input files can be in either .pdf, .bmp, .gif, .jpeg, .jpg, .png, or .tiff format. Extract the text from the response object with dai::text_from_dai_response(). Inspect the entire response object with httr::content().

Examples

if (FALSE) { response <- dai_sync("doc_page.pdf") my_page_scan <- "001.png" response <- dai_sync(my_page_scan) }