Skip to content

About

Extract, translate, and export PDF documents — batch processing, optional OCR, translation review/edit, 9 languages supported. Built with Streamlit.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PDF Translator

Extract text from PDFs, translate it, review the result, and export a new document. This Streamlit app supports single-file and batch workflows, with optional OCR for scanned pages.

Contents

Features

  • Extracts PDF text in reading order, with page, position, and font-size metadata.
  • Uses an optional two-column reading-order heuristic for common layouts.
  • Translates in manageable chunks, retries failed requests, and keeps source text when a block cannot be translated.
  • Lets you review and edit the translation, with optional glossary entries to keep terminology consistent.
  • Processes multiple PDFs and bundles completed documents into a ZIP archive.
  • Exports reflowed TXT, DOCX, PDF, and JSON files.
  • Caches extraction results during the session to avoid repeating work on routine reruns.
  • Checks PDF signatures, page counts, file sizes, encryption, and extracted-text limits.

Quick start

Use Python 3.10 or newer. Create a virtual environment, install the app dependencies, and launch Streamlit:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
streamlit run app.py

Streamlit opens the app in your browser, usually at http://localhost:8501.

OCR for scanned PDFs

OCR is optional. Install the Python packages and the system tools used to read scanned pages:

python -m pip install -r requirements-ocr.txt

On Debian or Ubuntu, install Tesseract and Poppler with:

sudo apt-get install tesseract-ocr poppler-utils

Install Tesseract language data for the languages in your scans. Package names and installation steps vary by operating system.

How to use the app

  1. Upload one or more PDF files.
  2. Choose the source and target languages, translation provider, and optional OCR settings.
  3. Review the extracted text, then start translation after confirming the provider's data flow.
  4. Edit the translated text if needed. Add glossary terms in source = translation format, one entry per line.
  5. Download an individual export or the ZIP archive for a multi-file run.

Languages

The app supports English, Indonesian, Vietnamese, French, Spanish, German, Japanese, Korean, and Simplified Chinese. You can also let the translation provider detect the source language automatically.

Translation providers and privacy

Google Translate is the default provider. The app asks for consent before sending extracted document text to this external service.

You can select LibreTranslate and provide a server URL with an optional API key. Document text is sent to that server. Use a self-hosted server if you want to keep processing under your control; the app cannot verify whether a configured server is local or private.

Exports and limitations

Exports are reconstructed, reflowed documents, not pixel-perfect copies of the original PDF. Complex tables, images, handwriting, links, exact typography, and mixed layouts may need manual review. DOCX heading levels are inferred from font-size metadata. OCR quality depends on scan resolution and installed language data. Inspect exported files before sharing them.

Password-protected, encrypted, and malformed PDFs are rejected. Translation provider limits and availability may vary.

File limits

Limit Maximum
PDF size 25 MB per file
Pages 100 per PDF
Extracted text 750,000 characters per PDF
Files per run 20 PDFs
Combined upload size 100 MB per run

Development

Install the test dependencies and run the test suite:

python -m pip install -r requirements-dev.txt
python -m pytest -q

Tests use fake translation providers, so they do not consume provider quota. They cover the upload and consent flow, multi-file processing, extraction metadata, translation batching and glossary handling, partial failures, and DOCX/PDF export.

About

Extract, translate, and export PDF documents — batch processing, optional OCR, translation review/edit, 9 languages supported. Built with Streamlit.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages