Guide

PDF Extraction architecture

Maintainer overview of the extraction pipeline, OCR layers, and public endpoints.

Flow

  1. Editor REST or WP-CLI schedules work through Action_Scheduler_Handler::schedule().
  2. Extraction_Service resolves the PDF (uploads dir or remote download), calls OCR_Orchestrator::extract_text(), and saves a pdf_extraction child post.
  3. OCR_Orchestrator tries providers by priority. Claude (priority 4) first; Gemini (priority 5) fallback. Each returns plain text, Markdown, and Gutenberg HTML.
  4. Rewrite_Rules intercepts /{slug}/extraction and /{slug}/text early in parse_request. Markdown serving prefers prc-markdown-for-agents when active.
  5. Content_Discovery adds alternate links, JSON-LD DigitalDocument, /llms.txt entries, and robots Allow rules.
Flow

Extraction pipeline

5 relationships
Async OCR path from trigger to public endpoints.

OCR layers

LayerNamespaceResponsibility
DomainOCR\DomainRequest/response types, exceptions
ApplicationOCR\ApplicationOrchestrator, validation, page analysis, merge
InfrastructureOCR\InfrastructureHTTP client, base64 encoder
ProvidersOCR\ProvidersClaude, Gemini, WP AI

Dependencies

  • Required: prc-platform-core, Action Scheduler
  • Optional: prc-markdown-for-agents (legacy Markdown template fallback when absent)
  • Env: PRC_PLATFORM_ANTHROPIC_API_KEY (Claude), PRC_PLATFORM_GOOGLE_API_KEY (Gemini)

Key files

PathPurpose
includes/class-bootstrap.phpModule wiring
includes/class-content-type.phppdf_extraction CPT + meta
includes/class-extraction-service.phpResolve PDF, OCR, save
includes/class-action-scheduler-handler.phpAsync queue + complete/failed actions
includes/class-rest-api.phpEditor convert/status
includes/class-rewrite-rules.phpPublic URL intercept
includes/class-content-discovery.phpDiscovery metadata
includes/class-wp-cli-commands.phpSingle-post CLI
includes/class-bulk-cli-command.phpBulk process (dry-run default)

Was this helpful?