Character, word, and text extraction over PDFBox's PDFTextStripper.
PDFTextStripper already reports direction-adjusted coordinates in a top-left
origin, so char maps are built directly from getXDirAdj/getYDirAdj without
a page-height flip. Words are formed by clustering chars into lines (within
:y-tolerance) and splitting on horizontal gaps wider than :x-tolerance.
Character, word, and text extraction over PDFBox's PDFTextStripper. PDFTextStripper already reports direction-adjusted coordinates in a top-left origin, so char maps are built directly from `getXDirAdj`/`getYDirAdj` without a page-height flip. Words are formed by clustering chars into lines (within `:y-tolerance`) and splitting on horizontal gaps wider than `:x-tolerance`.
(chars doc)(chars doc opts)Vector of character maps {:text :x0 :top :x1 :bottom :font-name :font-size :page-number}. Options: :page (1-based, limit to one page) and :bbox
(keep chars whose center falls inside [x0 top x1 bottom]).
Vector of character maps `{:text :x0 :top :x1 :bottom :font-name :font-size
:page-number}`. Options: `:page` (1-based, limit to one page) and `:bbox`
(keep chars whose center falls inside `[x0 top x1 bottom]`).(dedupe-char-records char-records)(dedupe-char-records char-records
{:keys [tolerance compare-attrs extra-attrs]
:or {tolerance 1.0}})Remove duplicate chars within positional :tolerance, comparing :text
plus configurable :compare-attrs (default fontname, size, upright).
Remove duplicate chars within positional `:tolerance`, comparing `:text` plus configurable `:compare-attrs` (default fontname, size, upright).
(dedupe-chars doc)(dedupe-chars doc opts)Extract chars and remove positional duplicates. Extraction and comparison options share the same map.
Extract chars and remove positional duplicates. Extraction and comparison options share the same map.
(extract-text doc)(extract-text doc opts)Pdfplumber-compatible text entry point, including :layout,
:keep-blank-chars, and :use-text-flow options.
Pdfplumber-compatible text entry point, including `:layout`, `:keep-blank-chars`, and `:use-text-flow` options.
(extract-text-lines doc)(extract-text-lines doc opts)Extract positional line maps. Each includes text, bounds, page number, and
contributing chars unless :return-chars false is supplied.
Extract positional line maps. Each includes text, bounds, page number, and contributing chars unless `:return-chars false` is supplied.
(extract-text-simple doc)(extract-text-simple doc
{:keys [x-tolerance y-tolerance]
:or {x-tolerance default-tolerance
y-tolerance default-tolerance}
:as opts})Fast text reconstruction by doctop line clustering and direct character-gap spacing, without building word or text maps.
Fast text reconstruction by doctop line clustering and direct character-gap spacing, without building word or text maps.
(extract-words doc)(extract-words doc opts)Pdfplumber-compatible entry point for words.
Pdfplumber-compatible entry point for `words`.
(search doc pattern)(search doc pattern opts)Search reconstructed text with a regex Pattern or string. Results include
match text, capture groups, bounds, and contributing chars. String patterns
are regexes by default; set :regex false for literal matching.
Search reconstructed text with a regex Pattern or string. Results include match text, capture groups, bounds, and contributing chars. String patterns are regexes by default; set `:regex false` for literal matching.
(text doc)(text doc opts)Reconstructed text: words joined by spaces within a line, lines by newlines.
Accepts the same options as words.
Reconstructed text: words joined by spaces within a line, lines by newlines. Accepts the same options as `words`.
(text-map doc)(text-map doc opts)Text output plus [source-char output-character] tuples. Inserted spaces and
newlines carry a nil source char.
Text output plus `[source-char output-character]` tuples. Inserted spaces and newlines carry a nil source char.
(word-map doc)(word-map doc opts)Word-to-source-character mapping. Returns :words and a parallel
:word-chars vector, preserving the TextPosition-derived char maps.
Word-to-source-character mapping. Returns `:words` and a parallel `:word-chars` vector, preserving the TextPosition-derived char maps.
(words doc)(words doc opts)Vector of word maps {:text :x0 :top :x1 :bottom :page-number}, reading order.
Options: :page, :bbox, :x-tolerance (default 3.0), :y-tolerance
(default 3.0).
Vector of word maps `{:text :x0 :top :x1 :bottom :page-number}`, reading order.
Options: `:page`, `:bbox`, `:x-tolerance` (default 3.0), `:y-tolerance`
(default 3.0).cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |