# pdfzip
A simple and efficient PDF compressor using Ghostscript. This tool allows you to compress PDF files with various levels of compression, making it ideal for reducing file sizes for storage or sharing.
## Features
- **Multiple Compression Levels:** Choose from five different levels of compression to suit your needs.
- **Improved Error Handling:** Provides detailed error messages to help diagnose issues.
- **Batch Processing:** Compress all PDF files in a folder with ease.
- **Cross-Platform Support:** Works on Windows, macOS, and Linux.
- **Optional Progress Display:** View compression progress and results directly in the console.
- **Different Output Formats:** Choose between PDF and PS (PostScript) formats for output files.
- **Backup Options:** Automatically create backups of original files if desired.
## Installation
You can install `pdfzip` using one of the following methods:
### Option 1: Install via pip
To install `pdfzip` from PyPI using pip, run the following command:
```bash
pip install pdfzip
```
### Option 2: Install via Git Clone
If you prefer to clone the repository and install manually, follow these steps:
1. **Clone the repository:**
```bash
git clone https://github.com/dev-r4hul/pdfzip.git
cd pdfzip
```
2. **Install the package:**
```bash
pip install .
```
3. **(Optional) Add the script to your PATH:**
Make sure the installation directory is in your system’s PATH, or create a symbolic link to `pdfzip` for easy access.
### Ghostscript Installation
Ensure that Ghostscript is installed on your system and available in your system's PATH. You can download it from the official [Ghostscript website](https://ghostscript.com/releases/index.html).
## Usage
`pdfzip` can be used from the command line to compress individual PDF files or entire directories of PDF files.
### Command-Line Arguments
Here are the available command-line arguments and their descriptions:
- **`input`** (required):
Path to the input PDF file or directory containing PDF files.
```bash
pdfzip input.pdf
pdfzip /path/to/pdf/directory
```
- **`-o, --out`** (optional):
Path to the output PDF file or directory for compressed PDFs. If not specified, the original file will be replaced (unless `--backup` is used).
```bash
pdfzip input.pdf -o compressed_output.pdf
pdfzip /path/to/pdf/directory -o /path/to/output/directory
```
- **`-c, --compress`** (optional, default=2):
Compression level from 0 to 4. Choose the appropriate level based on your needs:
- `0`: Default compression
- `1`: Prepress (high quality, larger size)
- `2`: Printer (good quality, suitable for print)
- `3`: eBook (medium quality, smaller size)
- `4`: Screen (low quality, smallest size)
```bash
pdfzip input.pdf -c 3
```
- **`-b, --backup`** (optional):
Create a backup of the original PDF file(s) before compression, appending `_BACKUP` to the filename.
```bash
pdfzip input.pdf -b
```
- **`--open`** (optional, default=False):
Open the PDF file after compression using the default PDF viewer for your system.
```bash
pdfzip input.pdf --open
```
- **`--format`** (optional, default=pdf):
Specify the output format (`pdf` or `ps`). The default format is `pdf`.
```bash
pdfzip input.pdf --format ps
```
### Examples
#### Compress a Single PDF File
Compress `document.pdf` with the default settings and replace the original file:
```bash
pdfzip document.pdf
```
Compress `document.pdf` with high compression for screen display and save as `compressed_document.pdf`:
```bash
pdfzip document.pdf -o compressed_document.pdf -c 4
```
#### Compress Multiple PDF Files in a Folder
Compress all PDFs in a folder with the printer setting and save in a separate output folder:
```bash
pdfzip /path/to/folder -o /path/to/output/folder -c 2
```
Backup original files before compressing:
```bash
pdfzip /path/to/folder -b
```
#### Open PDF After Compression
Compress `report.pdf` and open it with the default PDF viewer:
```bash
pdfzip report.pdf --open
```
### Error Handling
The script will provide detailed error messages if something goes wrong, such as:
- Invalid input path
- Unsupported file format
- Missing Ghostscript installation
### Troubleshooting
If you encounter any issues, ensure that Ghostscript is installed correctly and available in your system's PATH. If you need further assistance, please refer to the [Ghostscript documentation]((https://ghostscript.readthedocs.io/en/latest/current/Use.htm)).
Raw data
{
"_id": null,
"home_page": "https://github.com/dev-r4hul/pdfzip",
"name": "pdfzip",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Rahul Choudhary",
"author_email": "goodluckrahul@yahoo.com",
"download_url": "https://files.pythonhosted.org/packages/a1/23/128a18aa5d2ef0757c62295b1289b39e0bed9dcce476a3977a079b76c2cc/pdfzip-0.1.0.tar.gz",
"platform": null,
"description": "# pdfzip\n\nA simple and efficient PDF compressor using Ghostscript. This tool allows you to compress PDF files with various levels of compression, making it ideal for reducing file sizes for storage or sharing.\n\n## Features\n\n- **Multiple Compression Levels:** Choose from five different levels of compression to suit your needs.\n- **Improved Error Handling:** Provides detailed error messages to help diagnose issues.\n- **Batch Processing:** Compress all PDF files in a folder with ease.\n- **Cross-Platform Support:** Works on Windows, macOS, and Linux.\n- **Optional Progress Display:** View compression progress and results directly in the console.\n- **Different Output Formats:** Choose between PDF and PS (PostScript) formats for output files.\n- **Backup Options:** Automatically create backups of original files if desired.\n\n## Installation\n\nYou can install `pdfzip` using one of the following methods:\n\n### Option 1: Install via pip\n\nTo install `pdfzip` from PyPI using pip, run the following command:\n\n```bash\npip install pdfzip\n```\n\n### Option 2: Install via Git Clone\n\nIf you prefer to clone the repository and install manually, follow these steps:\n\n1. **Clone the repository:**\n\n ```bash\n git clone https://github.com/dev-r4hul/pdfzip.git\n cd pdfzip\n ```\n\n2. **Install the package:**\n\n ```bash\n pip install .\n ```\n\n3. **(Optional) Add the script to your PATH:**\n\n Make sure the installation directory is in your system\u2019s PATH, or create a symbolic link to `pdfzip` for easy access.\n\n### Ghostscript Installation\n\nEnsure that Ghostscript is installed on your system and available in your system's PATH. You can download it from the official [Ghostscript website](https://ghostscript.com/releases/index.html).\n\n## Usage\n\n`pdfzip` can be used from the command line to compress individual PDF files or entire directories of PDF files.\n\n### Command-Line Arguments\n\nHere are the available command-line arguments and their descriptions:\n\n- **`input`** (required): \n Path to the input PDF file or directory containing PDF files.\n \n ```bash\n pdfzip input.pdf\n pdfzip /path/to/pdf/directory\n ```\n\n- **`-o, --out`** (optional): \n Path to the output PDF file or directory for compressed PDFs. If not specified, the original file will be replaced (unless `--backup` is used).\n \n ```bash\n pdfzip input.pdf -o compressed_output.pdf\n pdfzip /path/to/pdf/directory -o /path/to/output/directory\n ```\n\n- **`-c, --compress`** (optional, default=2): \n Compression level from 0 to 4. Choose the appropriate level based on your needs:\n - `0`: Default compression\n - `1`: Prepress (high quality, larger size)\n - `2`: Printer (good quality, suitable for print)\n - `3`: eBook (medium quality, smaller size)\n - `4`: Screen (low quality, smallest size)\n\n ```bash\n pdfzip input.pdf -c 3\n ```\n\n- **`-b, --backup`** (optional): \n Create a backup of the original PDF file(s) before compression, appending `_BACKUP` to the filename.\n \n ```bash\n pdfzip input.pdf -b\n ```\n\n- **`--open`** (optional, default=False): \n Open the PDF file after compression using the default PDF viewer for your system.\n \n ```bash\n pdfzip input.pdf --open\n ```\n\n- **`--format`** (optional, default=pdf): \n Specify the output format (`pdf` or `ps`). The default format is `pdf`.\n\n ```bash\n pdfzip input.pdf --format ps\n ```\n\n### Examples\n\n#### Compress a Single PDF File\n\nCompress `document.pdf` with the default settings and replace the original file:\n\n```bash\npdfzip document.pdf\n```\n\nCompress `document.pdf` with high compression for screen display and save as `compressed_document.pdf`:\n\n```bash\npdfzip document.pdf -o compressed_document.pdf -c 4\n```\n\n#### Compress Multiple PDF Files in a Folder\n\nCompress all PDFs in a folder with the printer setting and save in a separate output folder:\n\n```bash\npdfzip /path/to/folder -o /path/to/output/folder -c 2\n```\n\nBackup original files before compressing:\n\n```bash\npdfzip /path/to/folder -b\n```\n\n#### Open PDF After Compression\n\nCompress `report.pdf` and open it with the default PDF viewer:\n\n```bash\npdfzip report.pdf --open\n```\n\n### Error Handling\n\nThe script will provide detailed error messages if something goes wrong, such as:\n\n- Invalid input path\n- Unsupported file format\n- Missing Ghostscript installation\n\n### Troubleshooting\n\nIf you encounter any issues, ensure that Ghostscript is installed correctly and available in your system's PATH. If you need further assistance, please refer to the [Ghostscript documentation]((https://ghostscript.readthedocs.io/en/latest/current/Use.htm)).\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A simple PDF compressor using Ghostscript",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/dev-r4hul/pdfzip"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7103485ea7e1718453401e395cd851e0891bc806dd27eebf0b2f360538c40fec",
"md5": "6d177dffb6a72dfd583df957d508355c",
"sha256": "ce443807bc62ce34e36feaf3cb875d8f1de416e1a2b5b8778c1e0fb622e1de0c"
},
"downloads": -1,
"filename": "pdfzip-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6d177dffb6a72dfd583df957d508355c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 7275,
"upload_time": "2024-08-03T11:00:02",
"upload_time_iso_8601": "2024-08-03T11:00:02.074318Z",
"url": "https://files.pythonhosted.org/packages/71/03/485ea7e1718453401e395cd851e0891bc806dd27eebf0b2f360538c40fec/pdfzip-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a123128a18aa5d2ef0757c62295b1289b39e0bed9dcce476a3977a079b76c2cc",
"md5": "ae1a41cadb6e48f544352ad50cf1db44",
"sha256": "e0274f79b9a75ee20e96c8086b50be7bfb478655c70845da6b3daa0c525d7dc7"
},
"downloads": -1,
"filename": "pdfzip-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ae1a41cadb6e48f544352ad50cf1db44",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 6418,
"upload_time": "2024-08-03T11:00:04",
"upload_time_iso_8601": "2024-08-03T11:00:04.470838Z",
"url": "https://files.pythonhosted.org/packages/a1/23/128a18aa5d2ef0757c62295b1289b39e0bed9dcce476a3977a079b76c2cc/pdfzip-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-03 11:00:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dev-r4hul",
"github_project": "pdfzip",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pdfzip"
}