Skip to content

Repository files navigation

pdf-wtf

PDF - what the file format ...

PDF files parsing and data extraction

Work in progress ...

CodeQL

Codacy Badge

Built on top of

pikepdf

PyMuPDF

ocrmypdf

External non-Python dependencies

Tesseract OCR

Ghostscript

unpaper

pngquant

Local dev installation

Prerequisites: Python 3.12+, Git

Open terminal/command line

  • create the repo dir
  • go to the dir
  1. Clone the repo:

    git clone https://github.com/filak/pdf-wtf

  2. Install uv package manager and create the virtual environment:

    pip install uv
    
    uv venv
    
  3. Activate the environment:

    .venv\Scripts\activate
    
  4. Install dependecies:

    uv sync
    
  5. Test - run:

    pytest
    

Updating the deps

uv add <package>==<version>

Using unpaper on Windows

OCRmyPDF requires unpaper installed to be able to use --clean and --clean_final params

Install and start Docker Desktop

Build the Docker image - run:

 docker build -t unpaper-alpine -f .Dockerfile-unpaper .

Test run:

 docker run --rm unpaper-alpine --version

Create ENV vars:

 setx PDFWTF_HOME_DIR d:\Decko\pdf-wtf
 setx PDFWTF_TEMP_DIR %PDFWTF_HOME_DIR%\instance\temp

Add %PDFWTF_HOME_DIR% to PATH so OCRmyPDF can find the unpaper.cmd

Check:

 echo  %PDFWTF_HOME_DIR%  %PDFWTF_TEMP_DIR%

 unpaper.cmd --version

Patch for ocrmypdf to use unpaper on Windows using Docker

\.venv\Lib\site-packages\ocrmypdf\subprocess\_windows.py#180  

def fix_windows_args():
...
# Patch for Windows - ".\\unpaper"
if sys.platform.startswith("win"):
    if args[0].startswith(".\\unpaper."):
        args[0] = args[0].lstrip(".\\")

If you reinstall the package - you MUST insert the patch again !

About

PDF parsing and data extraction

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages