Metadata-Version: 2.5
Name: pdf-remote-converter
Version: 2026.11.1
Summary: Converts MS Office documents (Word, Excel, Powerpoint) to PDF via API providers/remote access. Supported providers offer a generous free tier.
Project-URL: Repository, https://github.com/jr2804/pdf-remote-converter
Project-URL: Homepage, https://github.com/jr2804/pdf-remote-converter
Project-URL: Changelog, https://github.com/jr2804/pdf-remote-converter/releases
Project-URL: Documentation, https://jr2804.github.io/pdf-remote-converter/
Author-email: "Jan.Reimes" <Jan.Reimes@head-acoustics.com>
License: MIT
License-File: LICENSE
Keywords: cloudconvert,converter,docx,office,pdf
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.13
Requires-Dist: cyclopts>=5.0.0
Requires-Dist: google-auth>=2.53.0
Requires-Dist: hishel>=2.0.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pdfservices-sdk>=4.0.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-docx>=1.0.0
Description-Content-Type: text/markdown

# PDF Remote Converter

[![PyPI](https://img.shields.io/pypi/v/pdf-remote-converter.svg)](https://pypi.org/project/pdf-remote-converter/)
[![Python](https://img.shields.io/pypi/pyversions/pdf-remote-converter.svg)](https://pypi.org/project/pdf-remote-converter/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Converts MS Office documents (Word, Excel, Powerpoint) to PDF via API providers/remote access. Supported providers offer a generous free tier.

## Supported Providers

| Provider | Free Tier | Formats | Notes |
|----------|-----------|---------|-------|
| [CloudConvert](https://cloudconvert.com/) | 10 conversions/day | doc, docx, xls, xlsx, ppt, pptx | Default provider, async polling |
| [Adobe PDF Services](https://developer.adobe.com/) | 500 transactions/month | doc, docx, xls, xlsx, ppt, pptx | Requires client ID + secret |
| [ApyHub](https://apyhub.com/) | 5 conversions/day | doc, docx, xls, xlsx, ppt, pptx | Synchronous API, fast response |
| [Google Drive](https://drive.google.com/) | Unlimited | doc, docx, xls, xlsx, ppt, pptx | Requires service account JSON |
| [Zamzar](https://developers.zamzar.com/) | 100 credits/month | doc, docx, xls, xlsx, ppt, pptx | 1MB file size limit |

## Features

- **Multiple Cloud Providers**: Support for 5 different conversion backends with automatic failover
- **HTTP Caching**: Hishel-backed RFC 9111 caching for provider downloads (`--force` to bypass)
- **CLI and Library**: Use as a command-line tool or Python library
- **Automatic Failover**: Seamless fallback when providers are unavailable or quota exhausted
- **Modern Python**: Built with Python 3.13+, strict type checking, and 100% test coverage
- **Easy Configuration**: Environment variable-based setup with fallback API key support

## Documentation

For detailed documentation, see:

- [Installation Guide](docs/user-guide/installation.md)
- [Quickstart](docs/user-guide/quickstart.md)
- [CLI Reference](docs/user-guide/cli.md)
- [Configuration](docs/user-guide/configuration.md)
- [Supported Providers](docs/user-guide/providers.md)
- [Google Drive Setup](docs/user-guide/google-drive-setup.md)
- [Troubleshooting](docs/user-guide/troubleshooting.md)
- [Developer Guide](docs/developer-guide/architecture.md)
- [API Reference](docs/reference/api.md)

## Installation

```bash
# Install from PyPI (recommended)
uv tool install pdf-remote-converter
# or: pip install pdf-remote-converter
```

To work on the project itself:

```bash
# Clone the repository
git clone https://github.com/jr2804/pdf-remote-converter.git
cd pdf-remote-converter

# Install dependencies
uv sync --dev
```

## Usage

### CLI: Convert Office Documents to PDF

```bash
# Basic conversion (uses default configured provider)
pdf-remote-converter convert input.docx output.pdf

# Specify a provider explicitly
pdf-remote-converter convert --provider cloudconvert input.xlsx output.pdf
pdf-remote-converter convert --provider adobe input.pptx output.pdf
pdf-remote-converter convert --provider apyhub input.xlsx output.pdf
pdf-remote-converter convert --provider google_drive input.docx output.pdf

# Provide API key via command line
pdf-remote-converter convert --api-key YOUR_KEY --provider zamzar input.docx output.pdf

# Force fresh conversion (bypass HTTP cache)
pdf-remote-converter convert --force input.docx output.pdf

# Enable verbose logging for debugging
pdf-remote-converter convert --verbose input.docx output.pdf

# Show help and available options
pdf-remote-converter convert --help
```

### Configuration

All configuration is via environment variables. Set up your credentials:

```bash
# CloudConvert (10 conversions/day free tier)
export CLOUDCONVERT_API_KEY=your_api_key

# Adobe PDF Services (500 transactions/month free tier)
export ADOBE_CLIENT_ID=your_client_id
export ADOBE_CLIENT_SECRET=your_client_secret

# ApyHub (5 conversions/day free tier, synchronous API)
export APYHUB_API_KEY=your_api_token

# Google Drive (unlimited, requires service account)
export GOOGLE_DRIVE_CREDENTIALS=path/to/service_account.json

# Zamzar (100 credits/month free tier, 1MB max)
export ZAMZAR_API_KEY=your_api_key

# Optional: Generic fallback API key (used if provider-specific key not set)
export PDF_REMOTE_CONVERTER_API_KEY=your_fallback_key

# Optional: Default provider (default is cloudconvert)
export PDF_REMOTE_CONVERTER_DEFAULT_PROVIDER=cloudconvert

# Optional: Adaptive timeout range (seconds)
export PDF_REMOTE_CONVERTER_POLL_TIMEOUT_MIN=60
export PDF_REMOTE_CONVERTER_POLL_TIMEOUT_MAX=600

# Optional: Cache directory (default is ~/.cache/pdf-remote-converter)
export PDF_REMOTE_CONVERTER_CACHE_DIR=~/.cache/pdf-remote-converter
```

Copy `.env.example` to `.env` and fill in your credentials:

```bash
cp .env.example .env
# Edit .env with your API keys
```

### Running Tests

```bash
# Run all tests with coverage (100% coverage is enforced)
uv run pytest tests/ -v --cov=pdf_remote_converter --cov-report=term-missing
```

### Code Quality

The project uses [mise](https://mise.jdx.dev/) for task orchestration:

```bash
mise install         # install the pinned tool versions
mise dev            # uv sync -U --dev --all-extras --all-groups

mise lint           # ruff check --fix
mise spell          # codespell
mise typecheck      # ty (static type check)
mise format         # ruff format + ruff isort + pyreorder
mise format-md      # rumdl over Markdown
mise test           # pytest with coverage
mise all            # everything: test, lint, spell, format, format-md, docs
```

### Programmatic Usage (Python Library)

```python
from pdf_remote_converter import Converter

# Create converter with default settings
converter = Converter()

# Convert document
result = converter.convert("input.docx", "output.pdf")

# Check result
print(f"Converted by: {result.provider}")
print(f"From cache: {result.from_cache}")
print(f"Credits used: {result.credits_used}")

# Use specific provider
converter = Converter(provider="adobe")
result = converter.convert("input.xlsx", "output.pdf")

# Provide API key programmatically
converter = Converter(provider="cloudconvert", api_key="your_key")
result = converter.convert("input.pptx", "output.pdf")
```

## Development

### Setting Up Development Environment

```bash
# Install all dependencies including dev tools
uv sync --dev
```

### Pre-commit Hooks

Install pre-commit hooks to run quality checks before commits:

```bash
pre-commit install
pre-commit run --all-files
```

### Releasing

Push to `main` and the release workflow computes the CalVer tag, builds the
package, creates a GitHub release, publishes to PyPI, and mirrors the branch
and tags to the 3GPP Forge. Append `[skip release]` to the commit message to
skip a release.

### Building Documentation

```bash
uv run zensical build
```

## Project Structure

```text
pdf-remote-converter/
├── docs/                                   # Zensical documentation
├── src/pdf_remote_converter/
│   ├── __init__.py
│   ├── __about__.py                        # Version info
│   └── cli/                                # Cyclopts CLI module
├── tests/                                  # Pytest tests
├── .pre-commit-config.yaml                 # Pre-commit hooks configuration
├── ruff.toml                               # Ruff linter configuration
├── ty.toml                                 # ty type checker configuration
└── pyproject.toml                          # Project configuration
```

## Versioning

This project uses **Calendar Versioning** (`YYYY.MM.DD`). The version lives in
`pyproject.toml` and the release tag is `v<YYYY.MM.DD>`.

- Releases are cut automatically from `main` by the GitHub Actions release workflow
- Publishing to PyPI uses trusted publishing (OIDC), so no API token is stored
- The 3GPP Forge repository is kept as a read-only mirror of the GitHub repository

## License

This project is licensed under the **MIT** license.

See the [LICENSE](LICENSE) file for details.

## Contributing

We welcome contributions! Please see our [Contributing Guide](docs/contributing.md) for details.

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run quality checks: `uv run ruff check src/ tests/ && uv run ruff format src/ tests/ && uv run pytest tests/ -v --cov=pdf_remote_converter --cov-report=term-missing`
5. Submit a pull request

## Support

For issues and feature requests, please use the GitHub issue tracker.
