# HTML2PDF
**Repository Path**: mutudu0912/html2-pdf
## Basic Information
- **Project Name**: HTML2PDF
- **Description**: HTML文件转换成pdf
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-06-30
- **Last Updated**: 2026-07-06
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# HTML2PDF
A desktop application that converts HTML files to PDF using Playwright, supporting batch conversion and a graphical user interface.
## Features
- **HTML to PDF**: Uses the Playwright browser engine for high-quality HTML-to-PDF conversion
- **Batch Processing**: Supports simultaneous conversion of multiple HTML files with configurable concurrency
- **Archive Support**: Extracts HTML files from ZIP and TAR archives and converts them
- **Graphical Interface**: Provides a user-friendly drag-and-drop interface supporting file dropping
- **Auto-Restart**: Automatically restarts the browser process after prolonged operation to release resources
## Project Structure
```
html2-pdf/
├── archive.py # Archive file handling module
├── batch.py # Batch conversion handling module
├── converter.py # Core conversion module
├── discovery.py # File discovery module
└── gui.py # Graphical user interface module
```
## Installation Dependencies
```bash
pip install playwright
playwright install chromium
```
## Usage
### Command Line Usage
```bash
# Convert a single HTML file
python -m converter input.html output.pdf
# Batch convert all HTML files in a directory
python -m batch /path/to/html/files --output /path/to/output
# Convert HTML files from an archive
python -m converter archive.zip --output output_dir
```
### Graphical Interface
Launch the GUI by running `gui.py`:
```bash
python gui.py
```
Or use the bundled application (macOS).
## Configuration Options
### PdfOptions Configuration
- `scale`: PDF scale factor (default: 1.0)
- `print_background`: Whether to print background colors (default: True)
- `page_ranges`: Page range settings
- `margin`: Page margin settings
### Batch Configuration
- `concurrency`: Number of concurrent conversions (default: 4)
- `restart_after`: Restart browser after converting this many files (default: 50)
## Technology Stack
- **Python 3.14**: Core programming language
- **Playwright**: Browser automation tool
- **tkinter**: Python's standard GUI library
- **tkinterdnd2**: Drag-and-drop support
## License
MIT License