dai_sync_tab: OCR synchronously and get table data

View source: R/send_to_dai.R

dai_sync_tabR Documentation

OCR synchronously and get table data

Description

Sends a single document to the Google Cloud Services (GCS) Document AI v1beta2 API for synchronous (immediate) processing. Returns a response object containing the OCRed text and additional information, including table-related data.

Usage

dai_sync_tab(file, proj_id = get_project_id(), loc = "eu", token = dai_token())

Arguments

file

path to a single pdf or image file

proj_id

a GCS project id

loc

a two-letter region code ("eu" or "us")

token

An access token generated by dai_auth() or another auth function.

Details

This function accesses a different API endpoint than the main dai_sync() function, one that has less language support, but returns table data in addition to parsed text (which dai_sync() currently does not). This function may be deprecated if/when the v1 endpoint incorporates table extraction. Use of this service requires a GCS access token and some configuration of the .Renviron file; see vignettes for details. Input files can be in either .pdf, .bmp, .gif, .jpeg, .jpg, .png, or .tiff format. PDFs 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

## Not run: 
response <- dai_sync_tab("doc_page.pdf")

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

## End(Not run)

daiR documentation built on Sept. 8, 2023, 5:43 p.m.