Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active February 11, 2026 14:01
Show Gist options
  • Select an option

  • Save cderv/8ff05e294f3c66e8a0c735690a55f572 to your computer and use it in GitHub Desktop.

Select an option

Save cderv/8ff05e294f3c66e8a0c735690a55f572 to your computer and use it in GitHub Desktop.
Docker wrapper for verapdf PDF validation (for use with Quarto)

verapdf-docker

Docker wrapper for verapdf PDF validation, designed for use with Quarto but usable standalone.

What it does

This PowerShell script runs verapdf through Docker, avoiding the need to install Java and verapdf directly on your system.

Requirements

  • Docker Desktop installed and running
  • WSL distribution with Docker accessible
  • PowerShell with a docker function/command that forwards to Docker (via WSL or Docker Desktop)
  • Internet connection (for first run to pull Docker image)

Installation

Via Scoop (recommended for Quarto users)

If you use the r-bucket Scoop bucket:

scoop install verapdf-docker

This will:

  • Install the wrapper script
  • Create a verapdf-docker command available on your PATH
  • Automatically set QUARTO_VERAPDF=verapdf-docker environment variable

Manual installation

  1. Download verapdf-docker.ps1 from this gist
  2. Place it somewhere in your PATH
  3. Make it executable (PowerShell scripts are executable by default on Windows)
  4. For Quarto integration, set: $env:QUARTO_VERAPDF = "verapdf-docker"

Usage

With Quarto

Once installed via Scoop, Quarto will automatically use the Docker-based verapdf for PDF validation.

In your .qmd file YAML front matter:

---
format:
  pdf:
    pdf-standard: ua-2  # or a-2b, ua-1, etc.
---

Render your document:

quarto render document.qmd

Quarto will use Docker verapdf for validation instead of the built-in Java-based verapdf.

Standalone

You can also use the wrapper directly:

verapdf-docker -f ua2 document.pdf
verapdf-docker --help
verapdf-docker --version

How it works

  1. Checks if Docker is available
  2. Converts Windows paths to Unix-style paths for Docker volume mounts
  3. Runs verapdf/cli:latest Docker container with:
    • Current directory mounted as /data
    • All arguments passed through to verapdf
  4. Returns verapdf's exit code

Customization

The script uses your existing docker command/function. If you have a custom Docker setup (e.g., Docker via WSL), the script will automatically use it.

Troubleshooting

Error: "Docker is not running"

  • Start Docker Desktop
  • Wait for Docker to fully initialize
  • Verify with: docker version

Error: "Unable to find image 'verapdf/verapdf:latest'"

  • First run will pull the Docker image automatically (~500MB)
  • Requires internet connection
  • Takes 1-2 minutes for initial download

Quarto not using Docker wrapper

  • Check environment variable: $env:QUARTO_VERAPDF
  • Should be set to verapdf-docker
  • Restart PowerShell session after setting

License

Apache-2.0 (matches verapdf's license)

Links

# verapdf-docker.ps1
# Wrapper to run verapdf through Docker using WSL
# Check if Docker is available (via WSL)
try {
$null = docker version 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Error "Docker is not running or not installed. Please start Docker Desktop."
exit 1
}
} catch {
Write-Error "Docker is not available. Error: $_"
exit 1
}
# Get current directory for volume mount
$currentDir = Get-Location
$unixPath = $currentDir.Path -replace '\\', '/'
# Convert Windows drive letter to Unix-style (C:/ -> /c/)
$unixPath = $unixPath -replace '^([A-Z]):', {'/'+$_.Groups[1].Value.ToLower()}
# Run verapdf in Docker container
# Uses the existing docker function which forwards to WSL
docker run --rm -v "${unixPath}:/data" -w /data verapdf/cli:latest verapdf @args
# Return verapdf exit code
exit $LASTEXITCODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment