Skip to content

Commit ab61ca1

Browse files
authored
Merge pull request #1 from mostafaznv/dev
Dev
2 parents 80a10cc + 51becd7 commit ab61ca1

File tree

76 files changed

+1817
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1817
-22
lines changed

docs/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Introduction
2+
3+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mostafaznv/pdf-optimizer/run-tests.yml?branch=master\&label=Build\&style=flat-square\&logo=github)](https://github.com/mostafaznv/pdf-optimizer/actions) [![Codecov branch](https://img.shields.io/codecov/c/github/mostafaznv/pdf-optimizer/master.svg?style=flat-square\&logo=codecov)](https://app.codecov.io/gh/mostafaznv/pdf-optimizer) [![Quality Score](https://img.shields.io/scrutinizer/g/mostafaznv/pdf-optimizer.svg?style=flat-square)](https://scrutinizer-ci.com/g/mostafaznv/pdf-optimizer) [![GitHub license](https://img.shields.io/github/license/mostafaznv/pdf-optimizer?style=flat-square)](https://github.com/mostafaznv/pdf-optimizer/blob/master/LICENSE) [![Packagist Downloads](https://img.shields.io/packagist/dt/mostafaznv/pdf-optimizer?style=flat-square\&logo=packagist)](https://packagist.org/packages/mostafaznv/pdf-optimizer) [![Latest Version on Packagist](https://img.shields.io/packagist/v/mostafaznv/pdf-optimizer.svg?style=flat-square\&logo=composer)](https://packagist.org/packages/mostafaznv/pdf-optimizer)
4+
5+
6+
7+
**PDF Optimizer** stands as a robust PHP package meticulously crafted for effortless optimization and compression of PDF files. Whether you are engaged in a <mark style="color:red;">`standalone PHP`</mark> project or navigating the <mark style="color:red;">`Laravel`</mark> landscape, pdf-optimizer emerges as a powerful solution, utilizing the well-known <mark style="color:red;">`ghostscript`</mark> tool to significantly reduce PDF file sizes.
8+
9+
[![Donate](https://mostafaznv.github.io/donate/donate.svg)](https://mostafaznv.github.io/donate)
10+
11+
12+
13+
14+
15+
### Key Features
16+
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 <mark style="color:red;">`file`</mark><mark style="color:red;">` `</mark><mark style="color:red;">`paths`</mark>, <mark style="color:red;">`UploadedFile`</mark> instances, and <mark style="color:red;">`disk`</mark> 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.
22+
23+
24+

docs/SUMMARY.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Table of contents
2+
3+
## 🏁 Getting Started
4+
5+
* [Introduction](README.md)
6+
* [Installation](getting-started/installation.md)
7+
* [Support Us](getting-started/support-us.md)
8+
* [License](getting-started/license.md)
9+
10+
## 🚀 Basic Usage
11+
12+
* [Standalone PHP](basic-usage/standalone-php.md)
13+
* [Laravel](basic-usage/laravel.md)
14+
15+
## ⚙ Advanced Usage
16+
17+
* [Ghostscript Binary Configuration](advanced-usage/ghostscript-binary-configuration.md)
18+
* [Timeout](advanced-usage/timeout.md)
19+
* [Logger](advanced-usage/logger.md)
20+
* [Custom Ghostscript Options](advanced-usage/custom-ghostscript-options.md)
21+
* [Export Script](advanced-usage/export-script.md)
22+
* [Configuring Ghostscript](advanced-usage/configuring-ghostscript/README.md)
23+
* [ASCII85EncodePages](advanced-usage/configuring-ghostscript/ascii85encodepages.md)
24+
* [AutoFilterColorImages](advanced-usage/configuring-ghostscript/autofiltercolorimages.md)
25+
* [AutoFilterGrayImages](advanced-usage/configuring-ghostscript/autofiltergrayimages.md)
26+
* [AutoRotatePages](advanced-usage/configuring-ghostscript/autorotatepages.md)
27+
* [ColorConversionStrategy](advanced-usage/configuring-ghostscript/colorconversionstrategy.md)
28+
* [ColorImageDepth](advanced-usage/configuring-ghostscript/colorimagedepth.md)
29+
* [ColorImageFilter](advanced-usage/configuring-ghostscript/colorimagefilter.md)
30+
* [ColorImageDownsampleThreshold](advanced-usage/configuring-ghostscript/colorimagedownsamplethreshold.md)
31+
* [ColorImageDownsampleType](advanced-usage/configuring-ghostscript/colorimagedownsampletype.md)
32+
* [ColorImageResolution](advanced-usage/configuring-ghostscript/colorimageresolution.md)
33+
* [CompatibilityLevel](advanced-usage/configuring-ghostscript/compatibilitylevel.md)
34+
* [CompressFonts](advanced-usage/configuring-ghostscript/compressfonts.md)
35+
* [CompressPages](advanced-usage/configuring-ghostscript/compresspages.md)
36+
* [ConvertCMYKImagesToRGB](advanced-usage/configuring-ghostscript/convertcmykimagestorgb.md)
37+
* [DefaultRenderingIntent](advanced-usage/configuring-ghostscript/defaultrenderingintent.md)
38+
* [DetectDuplicateImages](advanced-usage/configuring-ghostscript/detectduplicateimages.md)
39+
* [DownsampleColorImages](advanced-usage/configuring-ghostscript/downsamplecolorimages.md)
40+
* [DownsampleGrayImages](advanced-usage/configuring-ghostscript/downsamplegrayimages.md)
41+
* [DownsampleMonoImages](advanced-usage/configuring-ghostscript/downsamplemonoimages.md)
42+
* [EmbedAllFonts](advanced-usage/configuring-ghostscript/embedallfonts.md)
43+
* [EncodeColorImages](advanced-usage/configuring-ghostscript/encodecolorimages.md)
44+
* [EncodeGrayImages](advanced-usage/configuring-ghostscript/encodegrayimages.md)
45+
* [EncodeMonoImages](advanced-usage/configuring-ghostscript/encodemonoimages.md)
46+
* [FastWebView](advanced-usage/configuring-ghostscript/fastwebview.md)
47+
* [GrayImageDepth](advanced-usage/configuring-ghostscript/grayimagedepth.md)
48+
* [GrayImageDownsampleThreshold](advanced-usage/configuring-ghostscript/grayimagedownsamplethreshold.md)
49+
* [GrayImageDownsampleType](advanced-usage/configuring-ghostscript/grayimagedownsampletype.md)
50+
* [GrayImageFilter](advanced-usage/configuring-ghostscript/grayimagefilter.md)
51+
* [GrayImageResolution](advanced-usage/configuring-ghostscript/grayimageresolution.md)
52+
* [LockDistillerParams](advanced-usage/configuring-ghostscript/lockdistillerparams.md)
53+
* [MaxInlineImageSize](advanced-usage/configuring-ghostscript/maxinlineimagesize.md)
54+
* [MaxSubsetPct](advanced-usage/configuring-ghostscript/maxsubsetpct.md)
55+
* [MonoImageDepth](advanced-usage/configuring-ghostscript/monoimagedepth.md)
56+
* [MonoImageDownsampleThreshold](advanced-usage/configuring-ghostscript/monoimagedownsamplethreshold.md)
57+
* [MonoImageDownsampleType](advanced-usage/configuring-ghostscript/monoimagedownsampletype.md)
58+
* [MonoImageFilter](advanced-usage/configuring-ghostscript/monoimagefilter.md)
59+
* [MonoImageResolution](advanced-usage/configuring-ghostscript/monoimageresolution.md)
60+
* [PassThroughJPEGImages](advanced-usage/configuring-ghostscript/passthroughjpegimages.md)
61+
* [PassThroughJPXImages](advanced-usage/configuring-ghostscript/passthroughjpximages.md)
62+
* [ParseDSCComments](advanced-usage/configuring-ghostscript/parsedsccomments.md)
63+
* [ParseDSCCommentsForDocInfo](advanced-usage/configuring-ghostscript/parsedsccommentsfordocinfo.md)
64+
* [PDFA](advanced-usage/configuring-ghostscript/pdfa.md)
65+
* [PDFACompatibilityPolicy](advanced-usage/configuring-ghostscript/pdfacompatibilitypolicy.md)
66+
* [PDFX](advanced-usage/configuring-ghostscript/pdfx.md)
67+
* [PreserveEPSInfo](advanced-usage/configuring-ghostscript/preserveepsinfo.md)
68+
* [PreserveHalftoneInfo](advanced-usage/configuring-ghostscript/preservehalftoneinfo.md)
69+
* [PreserveMarkedContent](advanced-usage/configuring-ghostscript/preservemarkedcontent.md)
70+
* [PreserveOPIComments](advanced-usage/configuring-ghostscript/preserveopicomments.md)
71+
* [PreserveOverprintSettings](advanced-usage/configuring-ghostscript/preserveoverprintsettings.md)
72+
* [ProcessColorModel](advanced-usage/configuring-ghostscript/processcolormodel.md)
73+
* [PDFSETTINGS](advanced-usage/configuring-ghostscript/pdfsettings.md)
74+
* [SubsetFonts](advanced-usage/configuring-ghostscript/subsetfonts.md)
75+
* [UCRandBGInfo](advanced-usage/configuring-ghostscript/ucrandbginfo.md)
76+
* [UseFlateCompression](advanced-usage/configuring-ghostscript/useflatecompression.md)
77+
78+
## 🎮 Laravel Deep Dive
79+
80+
* [Filesystem](laravel-deep-dive/filesystem.md)
81+
* [Queue](laravel-deep-dive/queue.md)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Configuring Ghostscript
2+
3+
In this section, we dive into the various methods provided by <mark style="color:red;">`pdf-optimizer`</mark> that leverage the capabilities of the powerful `ghostscript` tool. These methods empower you to fine-tune the optimization process and tailor it to your specific requirements. Whether you are seeking advanced configuration options or nuanced control over the compression process, this page serves as your guide to mastering pdf-optimizer's Ghostscript-related functionality.
4+
5+
6+
7+
8+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: ascii85EncodePages
3+
---
4+
5+
# ASCII85EncodePages
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ------------------ | ------------- | ------------- |
9+
| ascii85EncodePages | status | boolean |
10+
11+
If <mark style="color:red;">true</mark>, Distiller ASCII85-encodes binary streams such as page content streams, sampled images, and embedded fonts, resulting in a PDF file that is pure ASCII.
12+
13+
If <mark style="color:red;">false</mark>, Distiller does not encode the binary streams, resulting in a PDF file that may contain substantial amounts of binary data.
14+
15+
16+
17+
Distiller checks the value of this setting only once per document. Any change to it must be made before any marks are placed on the first page of the document.
18+
19+
20+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
description: autoFilterColorImages
3+
---
4+
5+
# AutoFilterColorImages
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| --------------------- | ------------- | ------------- |
9+
| autoFilterColorImages | status | boolean |
10+
11+
If <mark style="color:red;">true</mark>, the compression filter for color images is chosen based on the properties of each image, in conjunction with the `ColorImageAutoFilterStrategy` setting.
12+
13+
If <mark style="color:red;">false</mark>, all color sampled images are compressed using the filter specified by ColorImageFilter.
14+
15+
16+
17+
{% hint style="info" %}
18+
This setting is relevant only if <mark style="color:red;">EncodeColorImages</mark> is true.
19+
{% endhint %}
20+
21+
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
description: autoFilterGrayImages
3+
---
4+
5+
# AutoFilterGrayImages
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| -------------------- | ------------- | ------------- |
9+
| autoFilterGrayImages | status | boolean |
10+
11+
If <mark style="color:red;">true</mark>, the compression filter for gray images is chosen based on the properties of each image, in conjunction with the GrayImageAutoFilterStrategy setting.
12+
13+
If <mark style="color:red;">false</mark>, all color sampled images are compressed using the filter specified by GrayImageFilter.
14+
15+
16+
17+
{% hint style="info" %}
18+
This setting is relevant only if <mark style="color:red;">EncodeGrayImages</mark> is true.
19+
{% endhint %}
20+
21+
22+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
description: autoRotatePages
3+
---
4+
5+
# AutoRotatePages
6+
7+
<table><thead><tr><th width="182">Method Name</th><th width="159.33333333333331">Argument Name</th><th>Argument Type</th></tr></thead><tbody><tr><td>autoRotatePages</td><td>mode</td><td>Mostafaznv\PdfOptimizer\Enums\AutoRotatePages</td></tr></tbody></table>
8+
9+
Allows Distiller to automatically orient (rotate) pages based on the predominant text orientation. autorotation is not done if the file contains the <mark style="color:red;">%%ViewingOrientation</mark> DSC comment and <mark style="color:red;">ParseDSCComments</mark> is true.
10+
11+
If <mark style="color:red;">AutoRotatePages</mark> is set to <mark style="color:red;">None</mark>, pages are not automatically oriented and the <mark style="color:red;">%%ViewingOrientation</mark> DSC comment is ignored.
12+
13+
14+
15+
16+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: colorConversionStrategy
3+
---
4+
5+
# ColorConversionStrategy
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ----------------------- | ------------- | ----------------------------------------------------- |
9+
| colorConversionStrategy | strategy | Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy |
10+
11+
Sets the color conversion strategy, which includes the output color family and color space and the inclusion of ICC profiles.
12+
13+
14+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: colorImageDepth
3+
---
4+
5+
# ColorImageDepth
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| --------------- | ------------- | ---------------------------------------- |
9+
| colorImageDepth | depth | Mostafaznv\PdfOptimizer\Enums\ImageDepth |
10+
11+
Specifies the <mark style="color:red;">number of bits per color</mark> component in the output image.
12+
13+
14+
15+
**Allowed values are:**
16+
17+
* The number of bits per sample: 1, 2, 4, or 8.
18+
* \-1 , which forces the downsampled image to have the same number of bits per color component as the original image.
19+
20+
21+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: colorImageDownSampleThreshold
3+
---
4+
5+
# ColorImageDownsampleThreshold
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ----------------------------- | ------------- | ------------- |
9+
| colorImageDownSampleThreshold | threshold | float |
10+
11+
Sets the downsample threshold for color images.
12+
13+
This is the ratio of image resolution to output resolution above which downsampling may be performed. <mark style="color:red;">Must be between 1.0 through 10.0, inclusive.</mark>
14+
15+
16+
17+
{% hint style="info" %}
18+
If you set the threshold out of range, it reverts to a default of <mark style="color:red;">1.5</mark>
19+
{% endhint %}
20+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
description: colorImageDownSampleType
3+
---
4+
5+
# ColorImageDownsampleType
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ------------------------ | ------------- | ------------------------------------------------------ |
9+
| colorImageDownSampleType | type | Mostafaznv\PdfOptimizer\Enums\ColorImageDownSampleType |
10+
11+
Must be one of the following values:
12+
13+
* **Average (Average Downsampling to):** Groups of samples are averaged to get the new downsampled value.
14+
* **Bicubic (Bicubic Downsampling to):** Bicubic interpolation is used on a group of samples to get a new downsampled value.
15+
* **Subsample (Subsampling to):** The center sample from a group of samples is used as the new downsampled value.
16+
17+
18+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
description: colorImageFilter
3+
---
4+
5+
# ColorImageFilter
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ---------------- | ------------- | ----------------------------------------- |
9+
| colorImageFilter | filter | Mostafaznv\PdfOptimizer\Enums\ImageFilter |
10+
11+
Specifies the <mark style="color:red;">compression filter</mark> to be used for color images.&#x20;
12+
13+
Ignored if AutoFilterColorImages is true or EncodeColorImages is false.
14+
15+
16+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: colorImageResolution
3+
---
4+
5+
# ColorImageResolution
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| -------------------- | ------------- | ------------- |
9+
| colorImageResolution | resolution | int |
10+
11+
Specifies the resolution to which downsampled color images are reduced; <mark style="color:red;">valid values are 9 to 2400 pixels per inch.</mark>
12+
13+
14+
15+
{% hint style="info" %}
16+
A color image is downsampled if DownsampleColorImages is true and the resolution of the input image meets the criteria described in Downsampling and subsampling images.
17+
{% endhint %}
18+
19+
20+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: compatibilityLevel
3+
---
4+
5+
# CompatibilityLevel
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ------------------ | ------------------ | ------------------------------------------------ |
9+
| compatibilityLevel | compatibilityLevel | Mostafaznv\PdfOptimizer\Enums\CompatibilityLevel |
10+
11+
The PDF version number: <mark style="color:red;">**1.2, 1.3, 1.4, 1.5, 1.6, or 1.7**</mark>
12+
13+
14+
15+
{% hint style="info" %}
16+
Applications other than Distiller do not support saving files as PDF 1.2.
17+
{% endhint %}
18+
19+
20+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: compressFonts
3+
---
4+
5+
# CompressFonts
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ------------- | ------------- | ------------- |
9+
| compressFonts | status | bool |
10+
11+
Defines whether pdfwrite will compress embedded fonts in the output. <mark style="color:red;">The default value is true</mark>; the false setting is intended only for debugging as it will result in larger output.
12+
13+
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
description: compressPages
3+
---
4+
5+
# CompressPages
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ------------- | ------------- | ------------- |
9+
| compressPages | status | boolean |
10+
11+
If <mark style="color:red;">true</mark>, Flate compression is used to compress page content streams as well as form, pattern, and Type 3 font content streams.
12+
13+
InDesign also compresses ICC profiles, OutputIntentProfile and shading streams.
14+
15+
16+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: convertCmykImagesToRGB
3+
---
4+
5+
# ConvertCMYKImagesToRGB
6+
7+
8+
9+
| Method Name | Argument Name | Argument Type |
10+
| ---------------------- | ------------- | ------------- |
11+
| convertCmykImagesToRGB | status | boolean |
12+
13+
14+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: defaultRenderingIntent
3+
---
4+
5+
# DefaultRenderingIntent
6+
7+
| Method Name | Argument Name | Argument Type |
8+
| ---------------------- | --------------- | ---------------------------------------------------- |
9+
| defaultRenderingIntent | renderingIntent | Mostafaznv\PdfOptimizer\Enums\DefaultRenderingIntent |
10+
11+
Specifies the rendering intent for objects to be written to the PDF document, when not otherwise specified in the PostScript job by means of the findcolorrendering and setcolorrendering operators.
12+
13+
14+

0 commit comments

Comments
 (0)