draw_paragraphs: Draw paragraph bounding boxes on source document

View source: R/inspect_output.R

draw_paragraphsR Documentation

Draw paragraph bounding boxes on source document

Description

Plots the paragraph bounding boxes identified by Document AI (DAI) onto images of the submitted document. Generates an annotated .png file for each page in the original document.

Usage

draw_paragraphs(
  type,
  output,
  doc = NA,
  prefix = NULL,
  dir = getwd(),
  linecol = "red",
  linewd = 3,
  fontcol = "blue",
  fontsize = 4
)

Arguments

type

one of "sync", "async", "sync-tab" or "async-tab", depending on the function used to process the document.

output

either a HTTP response object (from dai_sync() or dai_sync_tab()) or the path to a JSON file (from dai_async or dai_async_tab()).

doc

filepath to the source document (pdf, tiff, or gif file); only necessary for documents processed with dai_sync_tab() or dai_async_tab().

prefix

string to be prepended to the output png filename.

dir

path to the desired output directory.

linecol

color of the bounding box line.

linewd

width of the bounding box line.

fontcol

color of the box numbers.

fontsize

size of the box numbers.

Details

Not vectorized, but documents can be multi-page.

Value

no return value, called for side effects.

Examples

## Not run: 
resp <- dai_sync("page.pdf")
draw_paragraphs(type = "sync",
                output = resp)

resp <- dai_sync_tab("page.pdf")
draw_paragraphs(type="sync-tab",
                output = resp,
                doc = "page.pdf")

draw_paragraphs(type = "async",
                output = "page.json")

draw_paragraphs(type = "async-tab",
                output = "page.json",
                doc = "page.pdf")

## End(Not run)

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