A fast, helpful, and open-source document parser
clean up dead code, align CLI interfaces
Logan Markewich87db738dcc1e
diff --git a/crates/liteparse-python/src/cli.rs b/crates/liteparse-python/src/cli.rsindex d4f1b4f..fb2dffc 100644--- a/crates/liteparse-python/src/cli.rs+++ b/crates/liteparse-python/src/cli.rs@@ -1,10 +1,8 @@use clap::{Args, Parser, Subcommand};use liteparse::config::{LiteParseConfig, OutputFormat};use liteparse::conversion;-use liteparse::extract;use liteparse::output::{json, text};use liteparse::parser::LiteParse;-use liteparse::render;#[derive(Parser, Debug)]#[command(@@ -25,10 +23,6 @@ enum Commands {Screenshot(ScreenshotCommand),/// Parse multiple documents in batch modeBatchParse(BatchParseCommand),- /// Extract raw text items from a PDF file (no grid projection) [dev tool]- Extract(ExtractCommand),- /// Extract embedded image bounding boxes from a page [dev tool]- ImageBounds(ExtractCommand),}#[derive(Args, Debug)]@@ -107,14 +101,6 @@ struct BatchParseCommand {num_workers: Option<usize>,}-#[derive(Args, Debug)]-struct ExtractCommand {- #[arg(long)]- pdf_path: String,- #[arg(long)]- page_num: Option<u32>,-}-fn parse_output_format(s: &str) -> Result<OutputFormat, String> {match s.to_lowercase().as_str() {"json" => Ok(OutputFormat::Json),@@ -302,13 +288,6 @@ pub fn run_cli(args: Vec<String>) -> Result<(), Box<dyn std::error::Error>> {std::process::exit(1);}}-- Commands::Extract(cmd) => {- extract::extract(&cmd.pdf_path, cmd.page_num)?;- }- Commands::ImageBounds(cmd) => {- render::image_bounds(&cmd.pdf_path, cmd.page_num)?;- }}Ok(())diff --git a/crates/liteparse-python/src/lib.rs b/crates/liteparse-python/src/lib.rsindex 5fe8d11..beb0f84 100644--- a/crates/liteparse-python/src/lib.rs+++ b/crates/liteparse-python/src/lib.rs@@ -183,6 +183,71 @@ impl PyScreenshotResult {}}+// ---------------------------------------------------------------------------+// Config+// ---------------------------------------------------------------------------++#[pyclass(frozen, from_py_object)]+#[derive(Clone)]+struct PyLiteParseConfig {+ #[pyo3(get)]+ ocr_language: String,+ #[pyo3(get)]+ ocr_enabled: bool,+ #[pyo3(get)]+ ocr_server_url: Option<String>,+ #[pyo3(get)]+ tessdata_path: Option<String>,+ #[pyo3(get)]+ max_pages: usize,+ #[pyo3(get)]+ target_pages: Option<String>,+ #[pyo3(get)]+ dpi: f32,+ #[pyo3(get)]+ output_format: String,+ #[pyo3(get)]+ preserve_very_small_text: bool,+ #[pyo3(get)]+ password: Option<String>,+ #[pyo3(get)]+ quiet: bool,+ #[pyo3(get)]+ num_workers: usize,+}++#[pymethods]+impl PyLiteParseConfig {+ fn __repr__(&self) -> String {+ format!(+ "LiteParseConfig(ocr_enabled={}, dpi={}, max_pages={})",+ self.ocr_enabled, self.dpi, self.max_pages+ )+ }+}++impl PyLiteParseConfig {+ fn from_rust(cfg: &LiteParseConfig) -> Self {+ Self {+ ocr_language: cfg.ocr_language.clone(),+ ocr_enabled: cfg.ocr_enabled,+ ocr_server_url: cfg.ocr_server_url.clone(),+ tessdata_path: cfg.tessdata_path.clone(),+ max_pages: cfg.max_pages,+ target_pages: cfg.target_pages.clone(),+ dpi: cfg.dpi,+ output_format: match cfg.output_format {+ OutputFormat::Json => "json".to_string(),+ OutputFormat::Text => "text".to_string(),+ },+ preserve_very_small_text: cfg.preserve_very_small_text,+ password: cfg.password.clone(),+ quiet: cfg.quiet,+ num_workers: cfg.num_workers,+ }+ }+}+// ---------------------------------------------------------------------------// Main LiteParse class// ---------------------------------------------------------------------------@@ -325,6 +390,12 @@ impl LiteParse {})}+ /// Get the resolved configuration.+ #[getter]+ fn config(&self) -> PyLiteParseConfig {+ PyLiteParseConfig::from_rust(&self.config)+ }+fn __repr__(&self) -> String {format!("LiteParse(ocr_enabled={}, dpi={}, max_pages={})",@@ -361,6 +432,7 @@ fn run_cli(args: Vec<String>) -> PyResult<()> {#[pymodule]fn _liteparse(m: &Bound<'_, PyModule>) -> PyResult<()> {m.add_class::<LiteParse>()?;+ m.add_class::<PyLiteParseConfig>()?;m.add_class::<PyParseResult>()?;m.add_class::<PyParsedPage>()?;m.add_class::<PyTextItem>()?;diff --git a/crates/liteparse/src/extract.rs b/crates/liteparse/src/extract.rsindex 18fa74a..09e9812 100644--- a/crates/liteparse/src/extract.rs+++ b/crates/liteparse/src/extract.rs@@ -14,35 +14,6 @@ pub(crate) fn load_document_from_input(}}-/// Extract pages from a PDF file and return them as structured data.-pub fn extract_pages(- pdf_path: &str,- page_num: Option<u32>,-) -> Result<Vec<LitePage>, LiteParseError> {- let target_pages: Option<Vec<u32>> = page_num.map(|p| vec![p]);- extract_pages_from_input(- &PdfInput::Path(pdf_path.to_string()),- target_pages.as_deref(),- usize::MAX,- None,- )-}--/// Extract pages with filtering by target page list and max pages, with optional password.-pub fn extract_pages_filtered(- pdf_path: &str,- target_pages: Option<&[u32]>,- max_pages: usize,- password: Option<&str>,-) -> Result<Vec<LitePage>, LiteParseError> {- extract_pages_from_input(- &PdfInput::Path(pdf_path.to_string()),- target_pages,- max_pages,- password,- )-}-/// Extract pages from a `PdfInput` (file path or bytes) with filtering.pub fn extract_pages_from_input(input: &PdfInput,@@ -99,7 +70,13 @@ pub(crate) fn extract_pages_from_document(/// Extract raw text items and print each page as a JSON-line object to stdout.pub fn extract(pdf_path: &str, page_num: Option<u32>) -> Result<(), LiteParseError> {- let pages = extract_pages(pdf_path, page_num)?;+ let target_pages: Option<Vec<u32>> = page_num.map(|p| vec![p]);+ let pages = extract_pages_from_input(+ &PdfInput::Path(pdf_path.to_string()),+ target_pages.as_deref(),+ usize::MAX,+ None,+ )?;for page in &pages {println!("{}", serde_json::to_string(page)?);}@@ -990,14 +967,13 @@ mod tests {}#[test]- fn extract_pages_missing_file_errors() {- let res = extract_pages("/nonexistent/path/does-not-exist.pdf", None);- assert!(res.is_err());- }-- #[test]- fn extract_pages_filtered_missing_file_errors() {- let res = extract_pages_filtered("/nonexistent/path/does-not-exist.pdf", None, 10, None);+ fn extract_pages_from_input_missing_file_errors() {+ let res = extract_pages_from_input(+ &PdfInput::Path("/nonexistent/path/does-not-exist.pdf".to_string()),+ None,+ usize::MAX,+ None,+ );assert!(res.is_err());}}diff --git a/crates/liteparse/src/main.rs b/crates/liteparse/src/main.rsindex f1bc82b..974ce94 100644--- a/crates/liteparse/src/main.rs+++ b/crates/liteparse/src/main.rs@@ -26,8 +26,10 @@ enum Commands {/// Parse multiple documents in batch modeBatchParse(BatchParseCommand),/// Extract raw text items from a PDF file (no grid projection) [dev tool]+ #[command(hide = true)]Extract(ExtractCommand),/// Extract embedded image bounding boxes from a page [dev tool]+ #[command(hide = true)]ImageBounds(ExtractCommand),}diff --git a/crates/liteparse/src/ocr_merge.rs b/crates/liteparse/src/ocr_merge.rsindex 5aa8f3d..acd4e24 100644--- a/crates/liteparse/src/ocr_merge.rs+++ b/crates/liteparse/src/ocr_merge.rs@@ -1,9 +1,8 @@use std::sync::Arc;use crate::error::LiteParseError;-use crate::extract::load_document_from_input;use crate::ocr::{OcrEngine, OcrOptions, OcrResult};-use crate::types::{Page, PdfInput, TextItem};+use crate::types::{Page, TextItem};use image::{ImageBuffer, Rgba};use pdfium::Document;@@ -15,48 +14,6 @@ pub(crate) struct RenderedPage {pub height: u32,}-/// Run OCR on pages that need it and merge results into text_items.-///-/// OCR is triggered when a page has fewer than 100 characters of native text-/// or has embedded images.-pub async fn ocr_and_merge_pages(- pages: &mut [Page],- pdf_path: &str,- dpi: f32,- ocr_engine: Arc<dyn OcrEngine>,- ocr_language: &str,- num_workers: usize,-) -> Result<(), LiteParseError> {- ocr_and_merge_pages_from_input(- pages,- &PdfInput::Path(pdf_path.to_string()),- dpi,- ocr_engine,- ocr_language,- num_workers,- None,- )- .await-}--/// Run OCR on pages that need it and merge results into text_items.-/// Accepts a `PdfInput` for either file path or in-memory bytes.-///-/// `num_workers` controls how many pages are OCR'd concurrently.-pub async fn ocr_and_merge_pages_from_input(- pages: &mut [Page],- input: &PdfInput,- dpi: f32,- ocr_engine: Arc<dyn OcrEngine>,- ocr_language: &str,- num_workers: usize,- password: Option<&str>,-) -> Result<(), LiteParseError> {- let document = load_document_from_input(input, password)?;- let rendered = render_pages_for_ocr(&document, pages, dpi)?;- ocr_and_merge_rendered(pages, rendered, dpi, ocr_engine, ocr_language, num_workers).await-}-/// Render pages that need OCR from an already-open document.////// The pdfium `Document` holds raw pointers that are not `Send`, so callers mustdiff --git a/crates/liteparse/src/output/json.rs b/crates/liteparse/src/output/json.rsindex 1b06b7d..98342bd 100644--- a/crates/liteparse/src/output/json.rs+++ b/crates/liteparse/src/output/json.rs@@ -2,7 +2,7 @@ use crate::types::ParsedPage;use serde::Serialize;#[derive(Debug, Serialize)]-pub struct JsonTextItem {+pub(crate) struct JsonTextItem {pub text: String,pub x: f32,pub y: f32,@@ -17,7 +17,7 @@ pub struct JsonTextItem {}#[derive(Debug, Serialize)]-pub struct JsonPage {+pub(crate) struct JsonPage {pub page: usize,pub width: f32,pub height: f32,@@ -26,12 +26,12 @@ pub struct JsonPage {}#[derive(Debug, Serialize)]-pub struct ParseResultJson {+pub(crate) struct ParseResultJson {pub pages: Vec<JsonPage>,}/// Build structured JSON output from parsed pages.-pub fn build_json(pages: &[ParsedPage]) -> ParseResultJson {+pub(crate) fn build_json(pages: &[ParsedPage]) -> ParseResultJson {ParseResultJson {pages: pages.iter()diff --git a/crates/liteparse/src/render.rs b/crates/liteparse/src/render.rsindex afe1294..53eb140 100644--- a/crates/liteparse/src/render.rs+++ b/crates/liteparse/src/render.rs@@ -93,24 +93,6 @@ pub fn screenshot(Ok(())}-/// Render a single page and write raw PNG bytes to stdout.-pub fn screenshot_to_stdout(- pdf_path: &str,- page_num: u32,- dpi: f32,- password: Option<&str>,-) -> Result<(), LiteParseError> {- let input = PdfInput::Path(pdf_path.to_string());- let pages = render_pages_to_png(&input, Some(&[page_num]), dpi, password)?;- let page = pages- .into_iter()- .next()- .ok_or_else(|| LiteParseError::Other("no page rendered".into()))?;-- std::io::Write::write_all(&mut std::io::stdout().lock(), &page.png_bytes)?;- Ok(())-}-#[derive(Debug, Serialize)]struct ImageBoundsOutput {x: f32,diff --git a/crates/liteparse/src/types.rs b/crates/liteparse/src/types.rsindex 97bdd63..4c34da2 100644--- a/crates/liteparse/src/types.rs+++ b/crates/liteparse/src/types.rs@@ -1,13 +1,6 @@-use serde::{Deserialize, Serialize};+use serde::Serialize;use std::collections::HashMap;-#[doc(hidden)]-#[derive(Debug, Serialize, Deserialize)]-pub enum InputType {- FilePath(String),- Buffer(Vec<u8>),-}-#[doc(hidden)]#[derive(Debug, Clone)]pub enum PdfInput {@@ -132,17 +125,6 @@ mod tests {}}- #[test]- fn input_type_roundtrip() {- let v = InputType::FilePath("/tmp/x.pdf".into());- let s = serde_json::to_string(&v).unwrap();- let back: InputType = serde_json::from_str(&s).unwrap();- match back {- InputType::FilePath(p) => assert_eq!(p, "/tmp/x.pdf"),- _ => panic!("wrong variant"),- }- }-#[test]fn text_item_skips_none_fields() {let item = sample_item();diff --git a/packages/node/src/cli.ts b/packages/node/src/cli.tsindex 435b798..e8478da 100644--- a/packages/node/src/cli.ts+++ b/packages/node/src/cli.ts@@ -2,8 +2,8 @@import { program } from "commander";import { LiteParse, type LiteParseConfig } from "./lib.js";-import { readFileSync } from "node:fs";-import { writeFileSync } from "node:fs";+import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync } from "node:fs";+import { join, relative, parse as parsePath } from "node:path";program.name("liteparse")@@ -92,4 +92,236 @@ program}});+program+ .command("screenshot")+ .description("Generate screenshots of document pages")+ .argument("<file>", "Path to the document file")+ .option(+ "-o, --output-dir <dir>",+ "Output directory for screenshots",+ "./screenshots",+ )+ .option(+ "--target-pages <pages>",+ 'Pages to screenshot (e.g., "1,3,5" or "1-5")',+ )+ .option("--dpi <dpi>", "Rendering DPI", parseFloat)+ .option("--password <password>", "Password for encrypted documents")+ .option("-q, --quiet", "Suppress progress output")+ .action(async (file: string, opts: Record<string, unknown>) => {+ try {+ const config: Partial<LiteParseConfig> = {};+ if (opts.dpi) config.dpi = opts.dpi as number;+ if (opts.password) config.password = opts.password as string;+ if (opts.quiet) config.quiet = true;+ if (opts.targetPages) config.targetPages = opts.targetPages as string;++ const parser = new LiteParse(config);++ // Parse target pages into number array+ let pageNumbers: number[] | undefined;+ if (opts.targetPages) {+ pageNumbers = [];+ for (const part of (opts.targetPages as string).split(",")) {+ const trimmed = part.trim();+ if (trimmed.includes("-")) {+ const [start, end] = trimmed.split("-").map(Number);+ for (let i = start; i <= end; i++) pageNumbers.push(i);+ } else {+ pageNumbers.push(Number(trimmed));+ }+ }+ }++ const outputDir = opts.outputDir as string;+ mkdirSync(outputDir, { recursive: true });++ const results = await parser.screenshot(file, pageNumbers);++ for (const result of results) {+ const outputPath = join(outputDir, `page_${result.pageNum}.png`);+ writeFileSync(outputPath, result.imageBuffer);+ if (!opts.quiet) {+ console.error(+ `[liteparse] screenshot page ${result.pageNum} → ${outputPath}`,+ );+ }+ }+ } catch (err) {+ console.error(+ `Error: ${err instanceof Error ? err.message : String(err)}`,+ );+ process.exit(1);+ }+ });++program+ .command("batch-parse")+ .description("Parse multiple documents in batch mode")+ .argument("<input-dir>", "Input directory")+ .argument("<output-dir>", "Output directory")+ .option("--format <format>", 'Output format: json|text (default: "text")')+ .option("--no-ocr", "Disable OCR")+ .option("--ocr-language <lang>", "OCR language (default: eng)")+ .option("--ocr-server-url <url>", "HTTP OCR server URL")+ .option("--max-pages <n>", "Max pages to parse per file", parseInt)+ .option("--dpi <dpi>", "Rendering DPI", parseFloat)+ .option("--recursive", "Recursively search input directory")+ .option("--extension <ext>", "Only process files with this extension")+ .option("--password <password>", "Password for encrypted documents")+ .option("-q, --quiet", "Suppress progress output")+ .option("--num-workers <n>", "Number of concurrent OCR workers", parseInt)+ .action(+ async (+ inputDir: string,+ outputDir: string,+ opts: Record<string, unknown>,+ ) => {+ try {+ const config: Partial<LiteParseConfig> = {};+ const format = (opts.format as string) ?? "text";+ config.outputFormat = format as "json" | "text";+ if (opts.ocr === false) config.ocrEnabled = false;+ if (opts.ocrLanguage) config.ocrLanguage = opts.ocrLanguage as string;+ if (opts.ocrServerUrl)+ config.ocrServerUrl = opts.ocrServerUrl as string;+ if (opts.maxPages) config.maxPages = opts.maxPages as number;+ if (opts.dpi) config.dpi = opts.dpi as number;+ if (opts.password) config.password = opts.password as string;+ if (opts.quiet) config.quiet = true;+ if (opts.numWorkers) config.numWorkers = opts.numWorkers as number;++ const parser = new LiteParse(config);+ const outExt = format === "json" ? ".json" : ".txt";++ mkdirSync(outputDir, { recursive: true });++ const extFilter = opts.extension+ ? (opts.extension as string).startsWith(".")+ ? (opts.extension as string).toLowerCase()+ : `.${(opts.extension as string).toLowerCase()}`+ : undefined;++ const files = collectFiles(+ inputDir,+ !!opts.recursive,+ extFilter,+ );++ if (files.length === 0) {+ console.error(+ `[liteparse] no matching files found in ${inputDir}`,+ );+ return;+ }+ if (!opts.quiet) {+ console.error(+ `[liteparse] found ${files.length} files to process`,+ );+ }++ let success = 0;+ let errors = 0;++ for (const filePath of files) {+ const t0 = Date.now();+ const rel = relative(inputDir, filePath);+ const parsed = parsePath(rel);+ const outPath = join(+ outputDir,+ parsed.dir,+ parsed.name + outExt,+ );+ mkdirSync(join(outputDir, parsed.dir), { recursive: true });++ try {+ const result = await parser.parse(filePath);+ const output =+ format === "json"+ ? JSON.stringify(+ {+ pages: result.pages.map((p) => ({+ page: p.pageNum,+ width: p.width,+ height: p.height,+ text: p.text,+ textItems: p.textItems,+ })),+ },+ null,+ 2,+ )+ : result.text;+ writeFileSync(outPath, output, "utf-8");+ success++;+ if (!opts.quiet) {+ const elapsed = Date.now() - t0;+ console.error(+ `[liteparse] ${filePath} → ${outPath} (${elapsed}ms)`,+ );+ }+ } catch (err) {+ console.error(+ `[liteparse] error parsing ${filePath}: ${err instanceof Error ? err.message : String(err)}`,+ );+ errors++;+ }+ }++ console.error(+ `[liteparse] batch complete: ${success} succeeded, ${errors} failed`,+ );+ if (errors > 0) process.exit(1);+ } catch (err) {+ console.error(+ `Error: ${err instanceof Error ? err.message : String(err)}`,+ );+ process.exit(1);+ }+ },+ );++const SUPPORTED_EXTENSIONS = new Set([+ ".pdf",+ ".doc", ".docx", ".docm", ".dot", ".dotm", ".dotx", ".odt", ".ott", ".rtf", ".pages",+ ".ppt", ".pptx", ".pptm", ".pot", ".potm", ".potx", ".odp", ".otp", ".key",+ ".xls", ".xlsx", ".xlsm", ".xlsb", ".ods", ".ots", ".csv", ".tsv", ".numbers",+ ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".webp", ".svg",+ ".txt", ".md", ".markdown", ".log",+]);++function collectFiles(+ dir: string,+ recursive: boolean,+ extFilter?: string,+): string[] {+ const files: string[] = [];+ collectFilesInner(dir, recursive, extFilter, files);+ files.sort();+ return files;+}++function collectFilesInner(+ dir: string,+ recursive: boolean,+ extFilter: string | undefined,+ files: string[],+): void {+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ const fullPath = join(dir, entry.name);+ if (entry.isDirectory()) {+ if (recursive) collectFilesInner(fullPath, recursive, extFilter, files);+ continue;+ }+ const lower = entry.name.toLowerCase();+ if (extFilter) {+ if (!lower.endsWith(extFilter)) continue;+ } else {+ const ext = lower.lastIndexOf(".") >= 0 ? lower.slice(lower.lastIndexOf(".")) : "";+ if (!SUPPORTED_EXTENSIONS.has(ext)) continue;+ }+ files.push(fullPath);+ }+}+program.parse(process.argv);diff --git a/packages/python/liteparse/__init__.py b/packages/python/liteparse/__init__.pyindex 659c0d4..f96f5d0 100644--- a/packages/python/liteparse/__init__.py+++ b/packages/python/liteparse/__init__.py@@ -1,5 +1,6 @@from .parser import LiteParse, search_itemsfrom .types import (+ LiteParseConfig,ParseResult,ParsedPage,TextItem,@@ -10,6 +11,7 @@ from .types import (__version__ = "2.0.0"__all__ = ["LiteParse",+ "LiteParseConfig","ParseResult","ParsedPage","TextItem",diff --git a/packages/python/liteparse/parser.py b/packages/python/liteparse/parser.pyindex af10bf0..019286a 100644--- a/packages/python/liteparse/parser.py+++ b/packages/python/liteparse/parser.py@@ -7,6 +7,7 @@ from liteparse._liteparse import LiteParse as _NativeLiteParsefrom liteparse._liteparse import search_items as _native_search_itemsfrom .types import (+ LiteParseConfig,ParsedPage,ParseError,ParseResult,@@ -70,7 +71,7 @@ class LiteParse:max_pages: Optional[int] = None,target_pages: Optional[str] = None,dpi: Optional[float] = None,-+ output_format: Optional[str] = None,preserve_very_small_text: Optional[bool] = None,password: Optional[str] = None,quiet: Optional[bool] = None,@@ -87,6 +88,7 @@ class LiteParse:max_pages: Maximum number of pages to parsetarget_pages: Specific pages to parse (e.g., "1-5,10,15-20")dpi: DPI for rendering (affects OCR quality)+ output_format: Output format: "json" or "text" (default: "json")preserve_very_small_text: Whether to preserve very small textpassword: Password for encrypted/protected documentsquiet: Suppress progress output@@ -107,6 +109,8 @@ class LiteParse:kwargs["target_pages"] = target_pagesif dpi is not None:kwargs["dpi"] = dpi+ if output_format is not None:+ kwargs["output_format"] = output_formatif preserve_very_small_text is not None:kwargs["preserve_very_small_text"] = preserve_very_small_textif password is not None:@@ -195,6 +199,24 @@ class LiteParse:except Exception as e:raise ParseError(str(e)) from e+ def get_config(self) -> LiteParseConfig:+ """Return the resolved configuration."""+ cfg = self._native.config+ return LiteParseConfig(+ ocr_language=cfg.ocr_language,+ ocr_enabled=cfg.ocr_enabled,+ ocr_server_url=cfg.ocr_server_url,+ tessdata_path=cfg.tessdata_path,+ max_pages=cfg.max_pages,+ target_pages=cfg.target_pages,+ dpi=cfg.dpi,+ output_format=cfg.output_format,+ preserve_very_small_text=cfg.preserve_very_small_text,+ password=cfg.password,+ quiet=cfg.quiet,+ num_workers=cfg.num_workers,+ )+def __repr__(self) -> str:return "LiteParse()"diff --git a/packages/python/liteparse/types.py b/packages/python/liteparse/types.pyindex 064e6fb..40f4fbf 100644--- a/packages/python/liteparse/types.py+++ b/packages/python/liteparse/types.py@@ -56,6 +56,23 @@ class ScreenshotResult:image_bytes: bytes+@dataclass+class LiteParseConfig:+ """Resolved parser configuration."""+ ocr_language: str+ ocr_enabled: bool+ ocr_server_url: Optional[str]+ tessdata_path: Optional[str]+ max_pages: int+ target_pages: Optional[str]+ dpi: float+ output_format: str+ preserve_very_small_text: bool+ password: Optional[str]+ quiet: bool+ num_workers: int++class ParseError(Exception):"""Exception raised when parsing fails."""pass