Это возможный ответ на вопрос о том, как распознать флажок. Не имея большего образца PDF, я не могу быть на 100% уверен, что это правильно. Я загрузил копию вашего изображения, чтобы сделать это.
library(tabulizer)
library(dplyr)
library(tibble)
library(tidyr)
library(readr)
library(stringr)
# path to your pdf
pdf_file <- "wF8L3.pdf"
# manually locate the area of text containing the check box
locate_areas(pdf_file)
# [[1]]
# top left bottom right
# 11.4404 197.3523 56.6117 316.4253
# I just copy and paste this into the extract_text function below
# extract pdf text
txt <-
extract_text(pdf_file, area = list(c(11.4404, 197.3523, 56.6117, 316.4253))) %>%
read_lines()
# turn into a tibble and wrangle
# this may not be the most efficient way and may need to be adapted for your use case.
# there is no magic. Data wrangling pdfs is a pain in my experience and requires alot of time.
# to determine if a box is ticked or not is done by inspection of the character which is generated by the tick box by the pdf reading process.
# For this to work it will need to be consistent in your document.
tib <-
tibble("gen" = txt[1],
"mf" = txt[2]) %>%
separate(col = mf, into = c("m", "f"), sep = "I") %>%
mutate(m_tick = case_when(str_detect(m, "o") ~ FALSE,
TRUE ~ TRUE),
f_tick = case_when(str_detect(f, "El") ~ TRUE,
TRUE ~ FALSE))
Надеюсь, вы сможете адаптировать это для своего варианта использования.