Metadata-Version: 2.1
Name: pdf2ppt-converter
Version: 1.0.1
Summary: Convert PDF files to PowerPoint presentations
Home-page: https://github.com/yourusername/pdf2ppt
Author: Your Name
Author-email: Your Name <your.email@example.com>
License: MIT
Project-URL: Homepage, https://github.com/yourusername/pdf2ppt
Project-URL: Documentation, https://github.com/yourusername/pdf2ppt#readme
Project-URL: Repository, https://github.com/yourusername/pdf2ppt.git
Project-URL: Issues, https://github.com/yourusername/pdf2ppt/issues
Keywords: pdf,powerpoint,ppt,converter,presentation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Topic :: Office/Business :: Office Suites
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
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: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pdf2image>=1.16.0
Requires-Dist: python-pptx>=0.6.21
Requires-Dist: Pillow>=9.0.0
Requires-Dist: numpy>=1.20.0

# pdf2ppt-converter

[![Python Version](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![PyPI](https://img.shields.io/pypi/v/pdf2ppt-converter.svg)](https://pypi.org/project/pdf2ppt-converter/)

A simple and easy-to-use Python library that converts PDF files to PowerPoint presentations by converting each page to an image.

## Features

- **One-click conversion** - Convert PDF to PPT with a single line of code
- **Auto-fit dimensions** - Automatically detects PDF aspect ratio and adjusts PPT size
- **High quality** - Supports custom DPI up to 600
- **Batch processing** - Convert multiple PDF files at once
- **Smart cropping** - Optional automatic white space cropping
- **Cross-platform** - Works on Windows, macOS, and Linux

## Installation

```bash
pip install pdf2ppt-converter
```

### Additional Requirements

**Windows users need to install poppler:**
1. Download from: https://github.com/oschwartz10612/poppler-windows/releases
2. Extract to a directory (e.g., `C:\poppler`)
3. Add `C:\poppler\Library\bin` to your system PATH

**macOS users:**
```bash
brew install poppler
```

**Linux users:**
```bash
# Ubuntu/Debian
sudo apt-get install poppler-utils

# Fedora/CentOS
sudo yum install poppler-utils
```

## Quick Start

### Basic Usage

```python
from pdf2ppt import pdf_to_ppt

# Simple conversion
pdf_to_ppt("presentation.pdf")
# Output: presentation.pptx

# Custom output and resolution
pdf_to_ppt("presentation.pdf", "output.pptx", dpi=300)
```

### Advanced Usage

```python
from pdf2ppt import PDF2PPT

# Create converter
converter = PDF2PPT("presentation.pdf", dpi=300, crop_whitespace=True)

# Convert PDF to images
images = converter.convert_pdf_to_images()
print(f"Converted {len(images)} pages")

# Create PPT (auto-fit aspect ratio)
converter.create_ppt()

# Or manually specify 16:9 ratio
converter.create_ppt(width=10, height=5.625)
```

### Batch Conversion

```python
from pdf2ppt import batch_convert

# Convert multiple PDFs
batch_convert(["doc1.pdf", "doc2.pdf", "doc3.pdf"], dpi=300)
```

### Command Line

After installation, you can use it directly from command line:

```bash
# Basic usage
pdf2ppt presentation.pdf

# Specify output file
pdf2ppt presentation.pdf output.pptx

# Specify resolution
pdf2ppt presentation.pdf output.pptx 200
```

## API Reference

### `pdf_to_ppt(pdf_path, output_ppt=None, dpi=300, crop_whitespace=True)`

Convenience function to convert PDF to PPT in one step.

**Parameters:**
- `pdf_path` (str): Path to input PDF file
- `output_ppt` (str, optional): Output PPT path, defaults to PDF name
- `dpi` (int, optional): Image resolution, default 300
- `crop_whitespace` (bool, optional): Whether to crop white borders, default True

**Returns:** str - Path to output PPT file

### `PDF2PPT` Class

#### Initialization

```python
converter = PDF2PPT(
    pdf_path="presentation.pdf",
    output_ppt="output.pptx",  # optional
    dpi=300,                    # optional
    crop_whitespace=True        # optional
)
```

#### Methods

**`convert_pdf_to_images() -> list`**
- Converts PDF to list of images
- Returns: List of PIL Image objects

**`create_ppt(width=10, height=None, auto_fit=True) -> str`**
- Creates PPT and inserts images
- Parameters:
  - `width` (float): PPT width in inches
  - `height` (float): PPT height in inches, auto-calculated if None
  - `auto_fit` (bool): Whether to auto-fit aspect ratio
- Returns: Path to output PPT file

**`convert() -> str`**
- One-step conversion: PDF → PPT
- Returns: Path to output PPT file

### `batch_convert(pdf_files, dpi=300, crop_whitespace=True)`

Convert multiple PDF files in batch.

**Parameters:**
- `pdf_files` (list): List of PDF file paths
- `dpi` (int, optional): Image resolution, default 300
- `crop_whitespace` (bool, optional): Whether to crop white borders, default True

## Configuration Guide

### DPI Settings

| DPI | Use Case | File Size | Quality |
|-----|----------|-----------|---------|
| 150 | Preview/Draft | Small | Fair |
| 200 | Daily use | Medium | Good |
| **300** | **Formal presentation (Recommended)** | Large | High |
| 600 | Print quality | Very large | Ultra |

### PPT Size Presets

| Aspect Ratio | Width x Height (inches) | Description |
|--------------|-------------------------|-------------|
| **16:9 (Recommended)** | 10 x 5.625 | Standard widescreen |
| 4:3 | 10 x 7.5 | Traditional format |
| A4 | 8.27 x 11.69 | For printing |

## Examples

### Example 1: Quick Conversion

```python
from pdf2ppt import pdf_to_ppt

# Default settings (300 DPI, auto-fit)
pdf_to_ppt("presentation.pdf")
```

### Example 2: Custom Settings

```python
from pdf2ppt import PDF2PPT

# Create converter
converter = PDF2PPT(
    pdf_path="presentation.pdf",
    output_ppt="high_quality.pptx",
    dpi=300,
    crop_whitespace=False  # Don't crop white borders
)

# Convert
converter.convert_pdf_to_images()
converter.create_ppt(width=10, height=5.625)  # 16:9 ratio
```

### Example 3: Batch Convert with Different DPI

```python
from pdf2ppt import pdf_to_ppt

pdfs = ["doc1.pdf", "doc2.pdf", "doc3.pdf"]

for pdf in pdfs:
    # Low DPI for preview
    pdf_to_ppt(pdf, pdf.replace(".pdf", "_preview.pptx"), dpi=150)

    # High DPI for formal use
    pdf_to_ppt(pdf, pdf.replace(".pdf", "_hq.pptx"), dpi=300)
```

## Troubleshooting

### Issue 1: "Unable to get page count"

**Cause:** Poppler not installed or not in PATH

**Solution:** Follow the poppler installation instructions above

### Issue 2: Out of Memory

**Cause:** DPI too high causing large images

**Solution:** Lower DPI (e.g., 150-200)

### Issue 3: Blurry Images

**Cause:** DPI too low

**Solution:** Increase DPI (recommended: 300)

## Development

### Clone Repository

```bash
git clone https://github.com/yourusername/pdf2ppt-converter.git
cd pdf2ppt-converter
```

### Install Development Dependencies

```bash
pip install -e ".[dev]"
```

### Run Tests

```bash
pytest tests/
```

## License

MIT License - see [LICENSE](LICENSE) file for details

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Acknowledgments

This project is built on these excellent open-source libraries:
- [pdf2image](https://github.com/Belval/pdf2image) - PDF to image conversion
- [python-pptx](https://github.com/scanny/python-pptx) - PowerPoint generation
- [Pillow](https://python-pillow.org/) - Image processing
- [NumPy](https://numpy.org/) - Numerical computing
