Declarative routing pipeline DSL on top of PdfInspector:
classify once, dispatch to a per-pdf_type strategy, aggregate.
Example
defmodule MyApp.DocPipeline do
use PdfInspector.Pipeline
route :text_based, :markdown # process/1 → full-doc markdown
route :mixed, :pages # extract_pages/2 → per-page markdown
route :scanned, {:ocr, MyApp.Ocr} # hand OCR pages to an Ocr behaviour impl
route :image_based, :skip # classification only, no content
fallback :classify # optional; default :classify
end
MyApp.DocPipeline.run(binary)
#=> {:ok, %PdfInspector.Pipeline.Result{}} | {:error, %PdfInspector.Error{}}Strategies
:markdown—PdfInspector.process/1, full-document markdown.:pages—PdfInspector.extract_pages/2(all pages), per-page markdown; pages flaggedneeds_ocrstay as placeholders and are listed inresult.ocr_pages.:classify— classification only.:skip— classification only, but marks the type as deliberately skipped (distinct from the fallback).{:ocr, module}—extract_pages/2first, then pages needing OCR are handed tomodule.extract(binary, pages)(seePdfInspector.Pipeline.Ocr); returned texts are merged into the corresponding pages.
Page indexing (upstream convention, unchanged)
result.classification.pages_needing_ocr, per-page page numbers,
result.ocr_pages and the pages argument of the OCR callback are all
0-indexed.
result.markdown for :pages / :ocr strategies is a convenience join of
the per-page markdowns with "\n\n" — the authoritative content is
result.pages (it is not guaranteed byte-identical to the :markdown
strategy's full-document output).
Classification errors (e.g. :encrypted) are propagated as
{:error, %PdfInspector.Error{}} without entering any strategy.
Summary
Functions
Strategy for pdf_types without an explicit route/2 (default :classify).
Route a pdf_type to a strategy. See the moduledoc for the strategy list.