Skip to contents

HTML gives the structure of a text without the layout noise of PDFs, so it is preferred when it is the full text. A page counts as the full text when it holds at least min_ratio of the words of the PDF.

Usage

prefer_html_text(html_text, pdf_path, min_ratio = 0.6)

Arguments

html_text

Character vector. Text of the page (paragraphs).

pdf_path

Character. Path of the PDF, whose text layer is read with pdftools.

min_ratio

Numeric. Minimum share of the words of the PDF.

Value

TRUE or FALSE. An unreadable PDF counts as having no words.

Details

The default of 0.6 comes from central_bank_database: a summary or landing page holds far fewer words (median ratio of about 1% for Bank of England publications with a PDF, measured in October 2026). It may not suit other sources.

Examples

if (FALSE) { # \dontrun{
prefer_html_text(paragraphs$text, "speech.pdf")
} # }