Pass a single-page pdf or image file to Document AI and get the output immediately:
library(daiR)
## Not run:
myfile <- "<sample.pdf>"
response <- dai_sync(myfile)
text <- text_from_dai_response(response)
cat(text)
Send larger batches for offline processing in three steps:
## Not run:
library(googleCloudStorageR)
my_pdfs <- c("<sample1.pdf>", "<sample2.pdf>")
purrr::map(my_pdfs, ~ gcs_upload(.x, name = .x))
## Not run:
dai_async(my_pdfs)
## Not run:
bucket_contents <- gcs_list_objects()
only_jsons <- grep("*.json", bucket_contents$name, value = TRUE)
map(only_jsons, ~ gcs_get_object(.x, saveToDisk = .x))
text <- text_from_dai_file(only_jsons[1])
cat(text)