|
7 | 7 | [](https://packagist.org/packages/mostafaznv/pdf-optimizer)
|
8 | 8 | [](https://packagist.org/packages/mostafaznv/pdf-optimizer)
|
9 | 9 |
|
10 |
| -PDF Optimizer is a powerful PHP package designed to optimize and compress PDF files effortlessly. Whether you're working on a `standalone PHP` project or a `Laravel` application, pdf-optimizer provides a seamless and efficient solution to reduce PDF file sizes using the popular `ghostscript` tool. |
11 |
| - |
12 |
| -### Features |
13 |
| -- **Fluent Method Chaining:** Enjoy a fluent and expressive API for optimizing PDF files with support for nearly all ghostscript options. |
14 |
| -- **Laravel Integration:** Specifically tailored for Laravel applications, pdf-optimizer supports various input methods, including file `paths`, `UploadedFile`, and `disk` storage. This ensures flexibility and ease of use within the Laravel ecosystem. |
15 |
| -- **Queue Support:** Optimize PDF files asynchronously with Laravel queues. pdf-optimizer seamlessly integrates with Laravel's queue system for efficient background processing. |
16 |
| - |
17 |
| - |
18 |
| ----- |
19 |
| -I am on an open-source journey 🚀, and I wish I could solely focus on my development path without worrying about my financial situation. However, as life is not perfect, I have to consider other factors. |
20 |
| - |
21 |
| -Therefore, if you decide to use my packages, please kindly consider making a donation. Any amount, no matter how small, goes a long way and is greatly appreciated. 🍺 |
| 10 | +`PDF Optimizer` stands as a robust PHP package meticulously crafted for effortless optimization and compression of PDF files. Whether you are engaged in a `standalone PHP` project or navigating the `Laravel` landscape, pdf-optimizer emerges as a powerful solution, utilizing the well-known `ghostscript` tool to significantly reduce PDF file sizes. |
22 | 11 |
|
23 | 12 | [](https://mostafaznv.github.io/donate)
|
24 | 13 |
|
25 | 14 | <br>
|
26 | 15 |
|
27 |
| - |
28 |
| -## Requirements: |
29 |
| - |
30 |
| -- PHP 8.2 or higher |
31 |
| -- [Ghostscript](https://ghostscript.com/) |
32 |
| - |
33 |
| -<br> |
34 |
| - |
35 |
| -## Install Ghostscript |
36 |
| - |
37 |
| -**Ubuntu** |
38 |
| -```shell |
39 |
| -apt-get install ghostscript |
40 |
| -``` |
41 |
| - |
42 |
| -**Alpine** |
43 |
| -```shell |
44 |
| -apk add --upgrade ghostscript |
45 |
| -``` |
46 |
| - |
47 |
| -**MacOS** |
48 |
| -```shell |
49 |
| -brew install ghostscript |
50 |
| -``` |
51 |
| - |
52 |
| -**Windows** (not tested) |
53 |
| -- Download and install [Ghostscript](https://www.ghostscript.com/download/gsdnld.html) |
54 |
| -- Add Ghostscript to your system path |
55 |
| -- Restart your computer |
56 |
| - |
57 |
| -<br> |
58 |
| - |
59 |
| -## Install Package |
60 |
| - |
61 |
| -1. ##### Install the package via composer: |
62 |
| - ```shell |
63 |
| - composer require mostafaznv/pdf-optimizer |
64 |
| - ``` |
65 |
| - |
66 |
| -2. ##### Publish config file (Laravel only): |
67 |
| - ```shell |
68 |
| - php artisan vendor:publish --provider="Mostafaznv\PdfOptimizer\PdfOptimizerServiceProvider" |
69 |
| - ``` |
70 |
| - |
71 |
| -3. ##### Done |
| 16 | +### Key Features |
| 17 | +- **Fluent Method Chaining:** Experience the elegance of a fluent and expressive API that seamlessly optimizes PDF files. Harness the power of nearly all ghostscript options with ease. |
| 18 | +- **Logger Support:** Capture detailed logs to gain profound insights into the intricacies of the optimization process. Stay informed and in control with the integrated logger. |
| 19 | +- **Customization:** Tailor the optimization process to your exact needs. pdf-optimizer provides a customizable solution, allowing you to fine-tune your PDF optimization experience. |
| 20 | +- **Laravel Integration:** Specifically designed for Laravel applications, pdf-optimizer supports diverse input methods, including `file paths`, `UploadedFile` instances, and `disk` storage. This guarantees flexibility and user-friendly integration within the Laravel ecosystem. |
| 21 | +- **Queue Support:** Elevate your optimization process with asynchronous PDF file optimization using Laravel queues. pdf-optimizer seamlessly integrates with Laravel's queue system, ensuring efficient background processing. |
72 | 22 |
|
73 | 23 | <br>
|
74 | 24 |
|
75 |
| -## Usage |
76 |
| - |
77 |
| -### Standalone PHP |
78 |
| - |
79 |
| -```php |
80 |
| -use Mostafaznv\PdfOptimizer\PdfOptimizer; |
81 |
| -use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; |
82 |
| -
|
83 |
| -$file = 'path/to/large.pdf'; |
84 |
| -$optimized = 'path/to/optimized.pdf'; |
85 |
| -
|
86 |
| -$result = PdfOptimizer::init() |
87 |
| - ->compressFonts() |
88 |
| - ->colorImageResolution(60) |
89 |
| - ->colorConversionStrategy(ColorConversionStrategy::DEVICE_INDEPENDENT_COLOR) |
90 |
| - ->optimize($file, $optimized); |
91 |
| -
|
92 |
| -var_dump($result); |
93 |
| -``` |
94 |
| - |
95 |
| -### Laravel |
96 |
| - |
97 |
| -```php |
98 |
| -use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; |
99 |
| -use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; |
100 |
| -use Mostafaznv\PdfOptimizer\Enums\PdfSettings; |
101 |
| -
|
102 |
| -$result = PdfOptimizer::fromDisk('files') |
103 |
| - ->open('input-1.pdf') |
104 |
| - ->toDisk('s3') |
105 |
| - ->settings(PdfSettings::SCREEN) |
106 |
| - ->colorConversionStrategy(ColorConversionStrategy::DEVICE_INDEPENDENT_COLOR) |
107 |
| - ->colorImageResolution(50) |
108 |
| - ->onQueue() |
109 |
| - ->optimize('output-1.pdf'); |
110 |
| -
|
111 |
| -dd($result); |
112 |
| -``` |
113 |
| - |
114 |
| ----- |
115 |
| -I am on an open-source journey 🚀, and I wish I could solely focus on my development path without worrying about my financial situation. However, as life is not perfect, I have to consider other factors. |
116 |
| - |
117 |
| -Therefore, if you decide to use my packages, please kindly consider making a donation. Any amount, no matter how small, goes a long way and is greatly appreciated. 🍺 |
118 |
| - |
119 |
| -[](https://mostafaznv.github.io/donate) |
120 |
| - |
121 |
| ----- |
122 |
| - |
123 |
| - |
124 |
| - |
125 |
| -## License |
126 |
| - |
127 |
| -This software is released under [The MIT License (MIT)](LICENSE). |
| 25 | +### Documentation |
| 26 | +You can find installation instructions and detailed instructions on how to use this package at the [dedicated documentation site.](https://mostafaznv.gitbook.io/pdf-optimizer) |
0 commit comments