Metadata-Version: 2.5
Name: pdfxr
Version: 1.1
Summary: Here is another tool to edit PDFs, but this time it's Strong to edit Raw PDFs (Hex) and Unicode Text !
Author-email: Abodx9 <abodx@gmx.de>
License-Expression: MIT
Keywords: Hex,PDFs,Raw,Text,Tools
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.11
Requires-Dist: fonttools
Requires-Dist: pypdf==6.16.1
Description-Content-Type: text/markdown

# PDFxr

**PDFxr** is a fast, command-line tool designed to replace Unicode and Hex text directly within PDF content streams. 

## Features
- **Direct Stream Replacement**: Modifies the underlying PDF streams directly for fast and precise text replacement.
- **Unicode & Hex Support**: Replace text using standard string replacements that are automatically encoded to the document's fonts.
- **Spacing Compensation**: Automatically compensates for `TJ` (Text Justification) width adjustments after text replacements to preserve document layout (can be disabled).
- **Strict Mode**: Optionally fail replacements if text is missing or the font cannot encode the requested characters.

## Installation

You can run the tool directly using [uv](https://github.com/astral-sh/uv), which will automatically handle dependencies:
```bash
uv add pdfxr
# then Run it
uv run pdfxr --help
```
Or simply use it in your standard Python environment.

## Usage

```bash
pdfxr [-h] [--replace OLD=NEW] [--no-preserve-advance] [--strict] input [output]
```

### Examples

**Basic replacement:**
```bash
pdfxr input.pdf output.pdf --replace "OldText=NewText"
```

**Multiple replacements:**
```bash
pdfxr document.pdf updated_document.pdf \
    --replace "Draft=Final" \
    --replace "2023=2024"
```

**Disable width compensation** (if characters are bunching up or spacing is incorrect):
```bash
pdfxr input.pdf output.pdf --replace "foo=bar" --no-preserve-advance
```

**Strict mode** (fails if the replacement target is not found):
```bash
pdfxr input.pdf output.pdf --replace "foo=bar" --strict
```

### Arguments

* `input`: The source PDF file.
* `output`: (Optional) The destination PDF file. Defaults to `output.pdf`.
* `--replace OLD=NEW`: The text replacement pair. You can supply this argument multiple times.
* `--no-preserve-advance`: Do not compensate `TJ` text widths after making replacements.
* `--strict`: Fail if the original text is missing or the selected font cannot encode the new text.
