Metadata-Version: 2.4
Name: pdf-watermark-cleaner
Version: 0.1.0
Summary: Surgical text and rotated watermark remover for PDF files without rasterization or quality loss.
License: MIT
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: fastapi>=0.110.0
Requires-Dist: pymupdf>=1.24.0
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: uvicorn>=0.28.0
Description-Content-Type: text/markdown

# PDF Watermark Remover

A lightweight, high-performance Python utility designed to surgically remove rotated and embedded text watermarks directly from PDF content streams without degrading original text or vector graphics.

---

## Features

- **Stream-Level Cleaning**: Intercepts and cleans PDF graphics content streams (`BT`/`ET` text objects).
- **Zero Quality Loss**: Preserves native text, vector shapes, layout, and document quality (no rasterization).
- **Modern Web Interface**: Built with FastAPI and a Drag & Drop UI on `http://localhost:8000`.
- **Interactive CLI**: Prompt-driven CLI with drag & drop path support and custom destination output prompts.
- **Fast Execution**: Powered by `PyMuPDF` (`fitz`) engine for high throughput.
- **MIT Licensed**: Open source license for personal and commercial use.

---

## Interfaces & Usage Options

### 1. Modern Web Application (FastAPI + Localhost)

Launch a modern, local web server with a drag-and-drop file interface:

```bash
# Using uv (recommended)
uv run python app.py

# Or standard python
python app.py
```

Then open your browser at **[http://localhost:8000](http://localhost:8000)** to drag and drop PDFs and download cleaned versions instantly.

---

### 2. Interactive CLI Mode

Run an interactive prompt that lets you drag & drop files into your terminal and select where to save the output:

```bash
# Using uv
uv run python cli.py

# Or standard python
python cli.py
```

**Example interaction:**
```text
📌 Enter or drag-and-drop the PDF file to clean: /path/to/my_document.pdf
📂 Default destination: /path/to/cleaned_my_document.pdf
📌 Enter destination path (press Enter to use default): /path/to/output_folder/

⚡ Processing PDF...
✨ Done! Clean file saved at: /path/to/output_folder/cleaned_my_document.pdf
```

---

### 3. Direct Command-Line Mode

Run directly with explicit flags:

```bash
# Using uv
uv run python remove_watermark.py -i input.pdf -o cleaned.pdf

# Or standard python
python remove_watermark.py -i input.pdf -o cleaned.pdf
```

---

### 4. Docker Container

```bash
# Build image
docker build -t pdf-watermark-remover .

# Run container
docker run --rm -v "$(pwd):/app/data" pdf-watermark-remover -i /app/data/input.pdf -o /app/data/cleaned.pdf
```

---

## Technical Overview

Traditional PDF redaction tools often overlay solid boxes or rasterize pages into images, destroying selectable text and increasing file sizes. 

This utility parses lower-level content stream graphics operators in PDF objects (`xref`) and strips watermark block signatures (e.g., specific rotation matrix parameters and watermark keyword operators). The output file is compressed and garbage-collected upon saving.

---

## License

This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
