### Activate Virtual Environment and Run OCRmyPDF Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html After installing dependencies with 'uv', activate the created virtual environment to use the 'ocrmypdf' command. This example shows how to check the help message. ```bash source .venv/bin/activate ocrmypdf --help ``` -------------------------------- ### Install OCRmyPDF and uv with pip on macOS Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the 'uv' package manager and then installs OCRmyPDF using pip for user installation. ```bash pip install uv uv pip install --user ocrmypdf ``` -------------------------------- ### Install OCRmyPDF with uv in a virtual environment Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using uv within a Python virtual environment. This is the recommended method for consistent installations. ```bash uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate uv pip install ocrmypdf ``` -------------------------------- ### Install OCRmyPDF with pip (user install) Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using pip with the --user flag, installing it for the current user only. This is an alternative to global installation. ```bash pip install --user ocrmypdf ``` -------------------------------- ### Install OCRmyPDF on Gentoo Linux Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Enables the 'guru' repository, synchronizes it, and installs OCRmyPDF on Gentoo Linux. ```bash eselect repository enable guru emaint sync --repo guru emerge --ask app-text/OCRmyPDF ``` -------------------------------- ### Example Settings File for OCRmyPDF Source: https://ocrmypdf.readthedocs.io/en/latest/releasenotes/version03.html This example shows the format for a settings file, with one argument per line. ```text -l deu --author A. Merkel --pdf-renderer tesseract ``` -------------------------------- ### Install OCRmyPDF with snap Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install OCRmyPDF using the snap package manager. This provides a self-contained package for installation. ```bash snap install ocrmypdf ``` -------------------------------- ### Clone OCRmyPDF and Install Dependencies with uv Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Clone the main branch of the OCRmyPDF repository and use 'uv' to install all dependencies within a virtual environment. This is the recommended method for installing from source. ```bash git clone -b main https://github.com/ocrmypdf/OCRmyPDF.git cd OCRmyPDF pip install uv # If not already installed uv sync ``` -------------------------------- ### Install All Tesseract Language Packs with Homebrew Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs all available language packs for Tesseract OCR using Homebrew. ```bash brew install tesseract-lang ``` -------------------------------- ### Build and Install jbig2enc from Source Source: https://ocrmypdf.readthedocs.io/en/latest/jbig2.html Clone the jbig2enc repository, navigate into the directory, and run the build and installation commands. This is necessary for systems not providing a pre-built package. ```bash git clone https://github.com/agl/jbig2enc cd jbig2enc ./autogen.sh ./configure && make [sudo] make install ``` -------------------------------- ### Install uv package manager Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the uv package manager, a fast and modern Python package manager recommended for installing OCRmyPDF. ```bash pip install uv ``` -------------------------------- ### Install OCRmyPDF with Homebrew Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF along with Tesseract, Ghostscript, and other dependencies using Homebrew. ```bash brew install ocrmypdf ``` -------------------------------- ### Install OCRmyPDF with dnf (Fedora) Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install OCRmyPDF and tesseract-osd using the dnf package manager on Fedora. This command ensures both OCRmyPDF and its necessary OCR engine are installed. ```bash dnf install ocrmypdf tesseract-osd ``` -------------------------------- ### Install OCRmyPDF globally with uv Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF globally using uv. This method is less recommended than using a virtual environment. ```bash uv pip install --system ocrmypdf ``` -------------------------------- ### Verify Docker Installation Source: https://ocrmypdf.readthedocs.io/en/latest/docker.html Run this command to ensure your system is ready to download and execute Docker images. ```bash docker run hello-world ``` -------------------------------- ### Install All Development and Test Requirements Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Clone the OCRmyPDF repository and install all development and test requirements using 'uv sync --all-groups'. This command ensures all necessary dependencies for development are present. ```bash git clone -b main https://github.com/ocrmypdf/OCRmyPDF.git cd OCRmyPDF uv sync --all-groups ``` -------------------------------- ### Install Optional User Features with uv Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install optional features for OCRmyPDF using 'uv'. The 'watcher' extra enables the file watching service, and 'webservice' enables the Streamlit web UI. Multiple features can be installed simultaneously. ```bash # Using uv (recommended) uv sync --extra watcher # File watching service uv sync --extra webservice # Streamlit web UI uv sync --extra watcher --extra webservice # Multiple features ``` -------------------------------- ### Install Additional Tesseract Language Packs on Windows Source: https://ocrmypdf.readthedocs.io/en/latest/languages.html Instructions for installing Tesseract language packs on Windows by downloading .traineddata files and placing them in the Tesseract tessdata folder. ```powershell # Example: Download and place a language pack file (e.g., spa.traineddata) # This is a conceptual example, actual download command would vary. # Copy-Item -Path "path/to/spa.traineddata" -Destination "C:\\Program Files\\Tesseract-OCR\\tessdata\\" ``` -------------------------------- ### Install JBIG2 Encoder Dependencies on Ubuntu Source: https://ocrmypdf.readthedocs.io/en/latest/jbig2.html Installs the necessary development packages for building the JBIG2 encoder on Ubuntu systems. Ensure autotools, automake, libtool, pkg-config, and leptonica are installed first. ```bash [sudo] apt install autotools-dev automake libtool libleptonica-dev pkg-config ``` -------------------------------- ### Install google-noto-fonts-common on Fedora Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the google-noto-fonts-common package on Fedora systems, recommended for proper text rendering. ```bash dnf install google-noto-fonts-common ``` -------------------------------- ### Install Italian Language Pack Source: https://ocrmypdf.readthedocs.io/en/latest/docker.html Installs the Tesseract OCR Italian language pack within the Docker image. ```dockerfile RUN apt install tesseract-ocr-ita ``` -------------------------------- ### Install latest OCRmyPDF on Ubuntu 22.04/24.04 LTS Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install system dependencies and then use pip with uv to install the latest version of OCRmyPDF on Ubuntu 22.04/24.04 LTS. This method bypasses potentially older distribution packages. ```bash # Install system dependencies first sudo apt-get update sudo apt-get -y install ocrmypdf # Install uv and upgrade to the latest OCRmyPDF pip install uv uv pip install --user --upgrade ocrmypdf ``` -------------------------------- ### Install Base Development Tools on Arch Linux Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the necessary base-devel package group for building packages on Arch Linux. ```bash sudo pacman -S --needed base-devel ``` -------------------------------- ### Install OCRmyPDF prerequisites in Cygwin64 Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Lists the necessary Cygwin packages to install for OCRmyPDF. These include Python, development tools, and libraries. ```bash python311 (or later) python3?-devel python3?-pip python3?-lxml python3?-imaging (where 3? means match the version of python3 you installed) gcc-g++ ghostscript libexempi3 libexempi-devel libffi6 libffi-devel pngquant qpdf libqpdf-devel tesseract-ocr tesseract-ocr-devel ``` -------------------------------- ### Install and Run OCRmyPDF Folder Watcher Source: https://ocrmypdf.readthedocs.io/en/latest/batch.html Instructions for installing and running the `watcher.py` script, which monitors input directories for new PDF files and processes them with OCRmyPDF. It can be run natively or within a Docker container. ```bash # Using uv (recommended) uv sync --extra watcher # Or using pip pip3 install ocrmypdf[watcher] env OCR_INPUT_DIRECTORY=/mnt/input-pdfs \ OCR_OUTPUT_DIRECTORY=/mnt/output-pdfs \ OCR_OUTPUT_DIRECTORY_YEAR_MONTH=1 \ python3 watcher.py ``` -------------------------------- ### Install OCRmyPDF on Alpine Linux Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using the Alpine Package Keeper (apk). ```bash apk add ocrmypdf ``` -------------------------------- ### Search and Install Chinese Simplified Language Pack on Debian/Ubuntu Source: https://ocrmypdf.readthedocs.io/en/latest/languages.html Searches for available Tesseract language packs and installs the Chinese Simplified pack using apt. ```bash # Display a list of all Tesseract language packs apt-cache search tesseract-ocr # Install Chinese Simplified language pack apt-get install tesseract-ocr-chi-sim ``` -------------------------------- ### Install Tesseract OCR with winget Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs Tesseract OCR using the winget package manager. This is a prerequisite for OCRmyPDF on Windows. ```bash winget install -e --id UB-Mannheim.TesseractOCR ``` -------------------------------- ### Install a Script Plugin Source: https://ocrmypdf.readthedocs.io/en/latest/plugins.html Use the --plugin argument to specify a script plugin file when running OCRmyPDF. Multiple plugins can be installed by repeating the argument. ```bash ocrmypdf --plugin ocrmypdf_example_plugin.py input.pdf output.pdf ``` -------------------------------- ### Install Development Tool Groups with uv Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install specific development tool dependency groups using 'uv'. This includes groups for testing infrastructure, documentation building, and enhanced Streamlit development. ```bash # Testing infrastructure uv sync --group test # Documentation building uv sync --group docs # Enhanced Streamlit development uv sync --group streamlit-dev # All development groups uv sync ``` -------------------------------- ### Install fonts-noto on Debian/Ubuntu Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the fonts-noto package on Debian or Ubuntu systems, recommended for proper text rendering. ```bash apt install fonts-noto ``` -------------------------------- ### Search and Install German Language Pack on Arch Linux Source: https://ocrmypdf.readthedocs.io/en/latest/languages.html Searches for available Tesseract language packs and installs the German pack using pacman. ```bash # Display a list of all Tesseract language packs pacman -Ss tesseract-data # Install German language pack pacman -S tesseract-data-deu ``` -------------------------------- ### Install OCRmyPDF with pipx Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using pipx, which creates an isolated environment for the command-line tool. This is useful for managing dependencies. ```bash pipx install ocrmypdf ``` -------------------------------- ### Search and Install Chinese Simplified Language Pack on Fedora Source: https://ocrmypdf.readthedocs.io/en/latest/languages.html Searches for available Tesseract language packs and installs the Chinese Simplified pack using dnf. ```bash # Display a list of all Tesseract language packs dnf search tesseract # Install Chinese Simplified language pack dnf install tesseract-langpack-chi_sim ``` -------------------------------- ### Install pypdfium2 with pip Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the pypdfium2 Python package, which provides fast PDF page rasterization and is preferred over Ghostscript. ```bash pip install pypdfium2 ``` -------------------------------- ### Install OCRmyPDF from AUR on Arch Linux Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Downloads, extracts, and installs the OCRmyPDF package from the Arch User Repository (AUR). ```bash curl -O https://aur.archlinux.org/cgit/aur.git/snapshot/ocrmypdf.tar.gz tar xvzf ocrmypdf.tar.gz cd ocrmypdf makepkg -sri ``` -------------------------------- ### Install English Tesseract Language Data on Arch Linux Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the English language data package for Tesseract OCR on Arch Linux. ```bash sudo pacman -S tesseract-data-eng ``` -------------------------------- ### Install font-noto with Homebrew on macOS Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the font-noto package on macOS using Homebrew, recommended for proper text rendering. ```bash brew install font-noto ``` -------------------------------- ### Install OCRmyPDF with Homebrew (macOS/Linux) Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Use Homebrew to install OCRmyPDF on macOS and Linux systems. This is a convenient one-liner for package management. ```bash brew install ocrmypdf ``` -------------------------------- ### Install Python 3.12 with winget Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs Python 3.12 using the winget package manager. This is a prerequisite for OCRmyPDF on Windows. ```bash winget install -e --id Python.Python.3.12 ``` -------------------------------- ### Prepare RHEL 9 environment for OCRmyPDF Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install Python 3.12 and pip on RHEL 9 systems to prepare for a virtual environment installation of OCRmyPDF. ```bash dnf install python3.12 python3.12-pip ``` -------------------------------- ### Install OCRmyPDF with apt (Debian/Ubuntu) Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install OCRmyPDF using the apt package manager on Debian and Ubuntu systems. Note that distribution versions may lag behind the latest release. ```bash apt install ocrmypdf ``` -------------------------------- ### Install OCRmyPDF Directly from GitHub using pip Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install the latest version of OCRmyPDF directly from its GitHub repository using pip. This is a convenient way to get the most recent code without cloning the repository manually. ```bash pip install git+https://github.com/ocrmypdf/OCRmyPDF.git ``` -------------------------------- ### Update Homebrew and Install Dependencies on macOS Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Updates Homebrew and installs or upgrades required packages for OCRmyPDF installation. ```bash brew update ``` -------------------------------- ### ocrmypdf.api.setup_plugin_infrastructure Source: https://ocrmypdf.readthedocs.io/en/latest/apiref.html Sets up the plugin infrastructure, including creating or validating the plugin manager, calling initialization hooks, and setting up the plugin option registry. ```APIDOC ## ocrmypdf.api.setup_plugin_infrastructure ### Description Sets up plugin infrastructure with proper initialization. This function handles creating or validating the plugin manager, calling plugin initialization hooks, and setting up the plugin option registry. ### Method [Function Call] ### Parameters - **plugins** (Sequence[Path | str] | None) - Optional - List of plugin paths/names to load. - **plugin_manager** (OcrmypdfPluginManager | None) - Optional - Existing plugin manager (if any). ### Returns - **OcrmypdfPluginManager** – Properly initialized plugin manager. ### Raises - **ValueError** – If both plugins and plugin_manager are provided. ``` -------------------------------- ### Install Tesseract OCR with Chocolatey Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs Tesseract OCR using the Chocolatey package manager. This is an alternative to winget for installing Tesseract on Windows. ```powershell choco install --pre tesseract ``` -------------------------------- ### Configure Logging Source: https://ocrmypdf.readthedocs.io/en/latest/apiref.html Set up logging to match the command-line interface behavior, including progress bars and colored output. This is optional. ```python import ocrmypdf ocrmypdf.configure_logging(ocrmypdf.Verbosity.default) ``` -------------------------------- ### Install Python 3 with Chocolatey Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs Python 3 using the Chocolatey package manager. This is an alternative to winget for installing Python on Windows. ```powershell choco install python3 ``` -------------------------------- ### Install OCRmyPDF with python3 -m pip Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using the python3 -m pip command. This is the standard method for installing Python packages. ```bash python3 -m pip install ocrmypdf ``` -------------------------------- ### Executor Setup for Parallel Execution Source: https://ocrmypdf.readthedocs.io/en/latest/plugins.html Illustrates the parameters required to set up parallel execution and progress reporting using the Executor class. This includes options for threading vs. multiprocessing, worker count, and custom initializers or task handlers. ```python Executor.__call__(_*_, _use_threads : bool_, _max_workers : int_, _progress_kwargs : dict_, _worker_initializer : Callable | None = None_, _task : Callable[[...], T] | None = None_, _task_arguments : Iterable | None = None_, _task_finished : Callable[[T, ProgressBar], None] | None = None_) → None ``` -------------------------------- ### Install OCRmyPDF with pkg (FreeBSD) Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Install OCRmyPDF on FreeBSD using the pkg package manager. This command installs the text processing package for OCRmyPDF. ```bash pkg install textproc/py-ocrmypdf ``` -------------------------------- ### Install OCRmyPDF with pip3 in Cygwin Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using pip3 within a Cygwin terminal. This assumes pip3 is the correct command for the installed pip version. ```bash pip3 install wheel pip3 install ocrmypdf ``` -------------------------------- ### configure_logging() Source: https://ocrmypdf.readthedocs.io/en/latest/apiref.html Sets up logging to match the command line interface behavior, supporting progress bars and colored output. ```APIDOC ## configure_logging() ### Description Configures the logging behavior to mimic the command-line interface, including support for progress bars and colored output. ### Method Python Function Call ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import ocrmypdf # Example using default verbosity ocrmypdf.configure_logging(ocrmypdf.Verbosity.default) ``` ### Response #### Success Response Configures the logging system. #### Response Example None explicitly defined. ``` -------------------------------- ### Install OCRmyPDF with py -m pip Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using the py -m pip command. This is used when Python was installed via WinGet on Windows. ```bash py -m pip install ocrmypdf ``` -------------------------------- ### Install OCRmyPDF with MacPorts Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs OCRmyPDF using the MacPorts package manager. ```bash sudo port install ocrmypdf ``` -------------------------------- ### Set Up OCRmyPDF Plugin Infrastructure Source: https://ocrmypdf.readthedocs.io/en/latest/apiref.html Initializes the plugin infrastructure for OCRmyPDF. This function handles the creation or validation of the plugin manager, plugin initialization, and option registry setup. It can load plugins from specified paths or names. ```python ocrmypdf.api.setup_plugin_infrastructure(_plugins : Sequence[Path | str] | None = None_, _plugin_manager : OcrmypdfPluginManager | None = None_) ``` -------------------------------- ### Install fpdf2 and uharfbuzz with pip Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs the fpdf2 and uharfbuzz Python packages, which are required for text layer rendering. ```bash pip install fpdf2 uharfbuzz ``` -------------------------------- ### Install pngquant with Chocolatey Source: https://ocrmypdf.readthedocs.io/en/latest/installation.html Installs pngquant using the Chocolatey package manager. This is an optional dependency for OCRmyPDF on Windows. ```powershell choco install pngquant ``` -------------------------------- ### Defining a Plugin Entry Point in pyproject.toml Source: https://ocrmypdf.readthedocs.io/en/latest/plugins.html Configure your project's pyproject.toml to define an entry point for your OCRmyPDF plugin. This allows OCRmyPDF to automatically load the plugin. ```toml [project] name = "ocrmypdf-exampleplugin" [project.entry-points."ocrmypdf"] exampleplugin = "exampleplugin.pluginmodule" ``` -------------------------------- ### OcrOptions Model Configuration and Methods Source: https://ocrmypdf.readthedocs.io/en/latest/apiref.html Configuration settings and serialization methods for the OcrOptions model. ```APIDOC ## OcrOptions Model Configuration and Methods ### Description Configuration settings and serialization methods for the OcrOptions model. ### Configuration - **model_config**: dict Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict]. Contains `arbitrary_types_allowed`, `extra`, and `validate_assignment` settings. ### Methods - **model_dump_json_safe() -> str** Serialize to JSON with special handling for non-serializable types. ```