A CLI tool to translate PDFs documents into another languages.
Project description
Adapter
A robust Python tool to translate PDF documents while preserving their original structure, including tables and formatting. It extracts text and tables intelligently, translates them using Google Translate, and rebuilds the document as a clean PDF.
Features
- Structure Preservation: Maintains the reading order of text and tables (unlike simple extractors).
- Table Support: Detects and translates table contents cell-by-cell.
- Multi-language: Supports translation between any languages supported by Google Translate.
- RTL Support: Automatically handles Right-to-Left languages like Urdu, Arabic, Persian, etc., with appropriate fonts.
Installation
You can install this package via pip (after building or if published):
pip install adapter
Or install from source:
git clone https://github.com/muhammad-asif10/adapter_cli.git
cd adapter
pip install .
Important: Install Playwright Browsers
This tool uses Playwright for high-quality PDF rendering. You must install the necessary browsers after installing the package:
playwright install chromium
Usage
CLI
You can use the command line interface adapter
adapter input.pdf output.pdf --source-lang english --target-lang urdu
Options:
input_pdf: Path to the source PDF file.output_pdf: Path where the translated PDF will be saved.-sl,--source-lang: Source language code or name (default: "english").-tl,--target-lang: Target language code or name (default: "urdu").--max-pages: (Optional) Limit the number of pages to process.
Python API
You can also use it as a library in your Python scripts:
from adapter import process_pdf
process_pdf(
input_pdf="document.pdf",
output_pdf="document_translated.pdf",
source_lang="english",
target_lang="spanish",
max_pages=5
)
Requirements
- Python 3.10+
pymupdfpdfplumberdeep-translatorplaywright
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glotext-0.1.0.tar.gz.
File metadata
- Download URL: glotext-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c655a03bb400098d51273c6a62744b408aa0a35b038a68e3d6c51e2fdc5da75
|
|
| MD5 |
e7a25a11ff76405c5e59509f615e0494
|
|
| BLAKE2b-256 |
b7adba7593c6eabdb6a6ec63ac7c836f1a49432946d56ddc2360c043d93dafa2
|
File details
Details for the file glotext-0.1.0-py3-none-any.whl.
File metadata
- Download URL: glotext-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c6701db4d124e5d9a7f7013a5937075bf27125486a57733013703825016c999
|
|
| MD5 |
de53000ac7a4eba391a8f07ce79da1a4
|
|
| BLAKE2b-256 |
d3c6dc3334f24fc28806abc982d480acf53e12b4611acee5673a977a75ecd476
|