pdfcheck is an R package that aims to make checking the accessibility of PDF files as easy as possible. It relies on verapdf (which does all the hard work in the background) and uses it to provide detailed reports on issues found in your PDF files.
Usage
- Make sure to install verapdf*:
pdfcheck::install_verapdf()*Should only do once and is not necessary if you already have the verapdf cli on PATH
- Check that a PDF is PDF/UA-1 compliant:
pdfcheck::is_pdf_compliant("report.pdf")
#> TRUE
# check for PDF/UA-2
pdfcheck::is_pdf_compliant("report.pdf", profile = "ua2")
#> FALSEIt works with many standards: profile can be any of ua1, ua2, 1a, 1b, 2a, 2b, 2u, 3a, 3b, 3u, 4, 4f, 4e. Default is ua1. You can find their meaning here.
- Generate an HTML accessibility report:
# Basic usage: this opens your browser
pdfcheck::accessibility_report("report.pdf")
# Explicit output file
pdfcheck::accessibility_report(
"report.pdf",
output_file = "report.html"
)
# Do not open browser
pdfcheck::accessibility_report(
"report.pdf",
output_file = "report.html",
open = FALSE
)
# Specify a different accessibility standard
pdfcheck::accessibility_report(
"report.pdf",
output_file = "report.html",
open = FALSE,
profile = "ua2"
)- Print an accessibility summary
pdfcheck::accessibility_summary("report.pdf")
#> PDF Accessibility Summary
#> =========================
#> Verapdf version: 1.28.2
#> Compliant: No
#> Profile: ua1
#>
#> Passed Rules: 95
#> Passed Checks: 591
#> Failed Rules: 11
#> Failed Checks: 195It is important to understand the difference between rules and checks. A rule that has been failed may be “Missing alternative text on images”, and each rule may have several checks that have been failed. For example, if the rule “Missing alt text on images” occurs 10 times in a given PDF (e.g., 10 images do not have an alternative text), that gives us 10 failed checks for that rule. More generally, a rule is a single issue, while a check corresponds to the number of times a rule has been failed.
- Get information and stats
pdfcheck::verapdf(pdf_file) |>
pdfcheck::get_total_failed_checks()
#> 195
pdfcheck::verapdf(pdf_file) |>
pdfcheck::get_total_failed_rules()
#> 11
pdfcheck::verapdf(pdf_file) |>
pdfcheck::get_verapdf_version()
#> "1.28.2"