Skip to content

Commit

Permalink
Merge pull request #1 from mostafaznv/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mostafaznv authored Jan 16, 2024
2 parents 80a10cc + 51becd7 commit ab61ca1
Show file tree
Hide file tree
Showing 76 changed files with 1,817 additions and 22 deletions.
24 changes: 24 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Introduction

[![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)



**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.

[![Donate](https://mostafaznv.github.io/donate/donate.svg)](https://mostafaznv.github.io/donate)





### Key Features

* **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.
* **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.
* **Customization:** Tailor the optimization process to your exact needs. pdf-optimizer provides a customizable solution, allowing you to fine-tune your PDF optimization experience.
* **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.
* **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.



81 changes: 81 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Table of contents

## 🏁 Getting Started

* [Introduction](README.md)
* [Installation](getting-started/installation.md)
* [Support Us](getting-started/support-us.md)
* [License](getting-started/license.md)

## 🚀 Basic Usage

* [Standalone PHP](basic-usage/standalone-php.md)
* [Laravel](basic-usage/laravel.md)

## ⚙ Advanced Usage

* [Ghostscript Binary Configuration](advanced-usage/ghostscript-binary-configuration.md)
* [Timeout](advanced-usage/timeout.md)
* [Logger](advanced-usage/logger.md)
* [Custom Ghostscript Options](advanced-usage/custom-ghostscript-options.md)
* [Export Script](advanced-usage/export-script.md)
* [Configuring Ghostscript](advanced-usage/configuring-ghostscript/README.md)
* [ASCII85EncodePages](advanced-usage/configuring-ghostscript/ascii85encodepages.md)
* [AutoFilterColorImages](advanced-usage/configuring-ghostscript/autofiltercolorimages.md)
* [AutoFilterGrayImages](advanced-usage/configuring-ghostscript/autofiltergrayimages.md)
* [AutoRotatePages](advanced-usage/configuring-ghostscript/autorotatepages.md)
* [ColorConversionStrategy](advanced-usage/configuring-ghostscript/colorconversionstrategy.md)
* [ColorImageDepth](advanced-usage/configuring-ghostscript/colorimagedepth.md)
* [ColorImageFilter](advanced-usage/configuring-ghostscript/colorimagefilter.md)
* [ColorImageDownsampleThreshold](advanced-usage/configuring-ghostscript/colorimagedownsamplethreshold.md)
* [ColorImageDownsampleType](advanced-usage/configuring-ghostscript/colorimagedownsampletype.md)
* [ColorImageResolution](advanced-usage/configuring-ghostscript/colorimageresolution.md)
* [CompatibilityLevel](advanced-usage/configuring-ghostscript/compatibilitylevel.md)
* [CompressFonts](advanced-usage/configuring-ghostscript/compressfonts.md)
* [CompressPages](advanced-usage/configuring-ghostscript/compresspages.md)
* [ConvertCMYKImagesToRGB](advanced-usage/configuring-ghostscript/convertcmykimagestorgb.md)
* [DefaultRenderingIntent](advanced-usage/configuring-ghostscript/defaultrenderingintent.md)
* [DetectDuplicateImages](advanced-usage/configuring-ghostscript/detectduplicateimages.md)
* [DownsampleColorImages](advanced-usage/configuring-ghostscript/downsamplecolorimages.md)
* [DownsampleGrayImages](advanced-usage/configuring-ghostscript/downsamplegrayimages.md)
* [DownsampleMonoImages](advanced-usage/configuring-ghostscript/downsamplemonoimages.md)
* [EmbedAllFonts](advanced-usage/configuring-ghostscript/embedallfonts.md)
* [EncodeColorImages](advanced-usage/configuring-ghostscript/encodecolorimages.md)
* [EncodeGrayImages](advanced-usage/configuring-ghostscript/encodegrayimages.md)
* [EncodeMonoImages](advanced-usage/configuring-ghostscript/encodemonoimages.md)
* [FastWebView](advanced-usage/configuring-ghostscript/fastwebview.md)
* [GrayImageDepth](advanced-usage/configuring-ghostscript/grayimagedepth.md)
* [GrayImageDownsampleThreshold](advanced-usage/configuring-ghostscript/grayimagedownsamplethreshold.md)
* [GrayImageDownsampleType](advanced-usage/configuring-ghostscript/grayimagedownsampletype.md)
* [GrayImageFilter](advanced-usage/configuring-ghostscript/grayimagefilter.md)
* [GrayImageResolution](advanced-usage/configuring-ghostscript/grayimageresolution.md)
* [LockDistillerParams](advanced-usage/configuring-ghostscript/lockdistillerparams.md)
* [MaxInlineImageSize](advanced-usage/configuring-ghostscript/maxinlineimagesize.md)
* [MaxSubsetPct](advanced-usage/configuring-ghostscript/maxsubsetpct.md)
* [MonoImageDepth](advanced-usage/configuring-ghostscript/monoimagedepth.md)
* [MonoImageDownsampleThreshold](advanced-usage/configuring-ghostscript/monoimagedownsamplethreshold.md)
* [MonoImageDownsampleType](advanced-usage/configuring-ghostscript/monoimagedownsampletype.md)
* [MonoImageFilter](advanced-usage/configuring-ghostscript/monoimagefilter.md)
* [MonoImageResolution](advanced-usage/configuring-ghostscript/monoimageresolution.md)
* [PassThroughJPEGImages](advanced-usage/configuring-ghostscript/passthroughjpegimages.md)
* [PassThroughJPXImages](advanced-usage/configuring-ghostscript/passthroughjpximages.md)
* [ParseDSCComments](advanced-usage/configuring-ghostscript/parsedsccomments.md)
* [ParseDSCCommentsForDocInfo](advanced-usage/configuring-ghostscript/parsedsccommentsfordocinfo.md)
* [PDFA](advanced-usage/configuring-ghostscript/pdfa.md)
* [PDFACompatibilityPolicy](advanced-usage/configuring-ghostscript/pdfacompatibilitypolicy.md)
* [PDFX](advanced-usage/configuring-ghostscript/pdfx.md)
* [PreserveEPSInfo](advanced-usage/configuring-ghostscript/preserveepsinfo.md)
* [PreserveHalftoneInfo](advanced-usage/configuring-ghostscript/preservehalftoneinfo.md)
* [PreserveMarkedContent](advanced-usage/configuring-ghostscript/preservemarkedcontent.md)
* [PreserveOPIComments](advanced-usage/configuring-ghostscript/preserveopicomments.md)
* [PreserveOverprintSettings](advanced-usage/configuring-ghostscript/preserveoverprintsettings.md)
* [ProcessColorModel](advanced-usage/configuring-ghostscript/processcolormodel.md)
* [PDFSETTINGS](advanced-usage/configuring-ghostscript/pdfsettings.md)
* [SubsetFonts](advanced-usage/configuring-ghostscript/subsetfonts.md)
* [UCRandBGInfo](advanced-usage/configuring-ghostscript/ucrandbginfo.md)
* [UseFlateCompression](advanced-usage/configuring-ghostscript/useflatecompression.md)

## 🎮 Laravel Deep Dive

* [Filesystem](laravel-deep-dive/filesystem.md)
* [Queue](laravel-deep-dive/queue.md)
8 changes: 8 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Configuring Ghostscript

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.





20 changes: 20 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/ascii85encodepages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
description: ascii85EncodePages
---

# ASCII85EncodePages

| Method Name | Argument Name | Argument Type |
| ------------------ | ------------- | ------------- |
| ascii85EncodePages | status | boolean |

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.

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.



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.



Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
description: autoFilterColorImages
---

# AutoFilterColorImages

| Method Name | Argument Name | Argument Type |
| --------------------- | ------------- | ------------- |
| autoFilterColorImages | status | boolean |

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.

If <mark style="color:red;">false</mark>, all color sampled images are compressed using the filter specified by ColorImageFilter.



{% hint style="info" %}
This setting is relevant only if <mark style="color:red;">EncodeColorImages</mark> is true.
{% endhint %}



Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
description: autoFilterGrayImages
---

# AutoFilterGrayImages

| Method Name | Argument Name | Argument Type |
| -------------------- | ------------- | ------------- |
| autoFilterGrayImages | status | boolean |

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.

If <mark style="color:red;">false</mark>, all color sampled images are compressed using the filter specified by GrayImageFilter.



{% hint style="info" %}
This setting is relevant only if <mark style="color:red;">EncodeGrayImages</mark> is true.
{% endhint %}



16 changes: 16 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/autorotatepages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: autoRotatePages
---

# AutoRotatePages

<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>

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.

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.





Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
description: colorConversionStrategy
---

# ColorConversionStrategy

| Method Name | Argument Name | Argument Type |
| ----------------------- | ------------- | ----------------------------------------------------- |
| colorConversionStrategy | strategy | Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy |

Sets the color conversion strategy, which includes the output color family and color space and the inclusion of ICC profiles.



21 changes: 21 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/colorimagedepth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
description: colorImageDepth
---

# ColorImageDepth

| Method Name | Argument Name | Argument Type |
| --------------- | ------------- | ---------------------------------------- |
| colorImageDepth | depth | Mostafaznv\PdfOptimizer\Enums\ImageDepth |

Specifies the <mark style="color:red;">number of bits per color</mark> component in the output image.



**Allowed values are:**

* The number of bits per sample: 1, 2, 4, or 8.
* \-1 , which forces the downsampled image to have the same number of bits per color component as the original image.



Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
description: colorImageDownSampleThreshold
---

# ColorImageDownsampleThreshold

| Method Name | Argument Name | Argument Type |
| ----------------------------- | ------------- | ------------- |
| colorImageDownSampleThreshold | threshold | float |

Sets the downsample threshold for color images.

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>



{% hint style="info" %}
If you set the threshold out of range, it reverts to a default of <mark style="color:red;">1.5</mark>
{% endhint %}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
description: colorImageDownSampleType
---

# ColorImageDownsampleType

| Method Name | Argument Name | Argument Type |
| ------------------------ | ------------- | ------------------------------------------------------ |
| colorImageDownSampleType | type | Mostafaznv\PdfOptimizer\Enums\ColorImageDownSampleType |

Must be one of the following values:

* **Average (Average Downsampling to):** Groups of samples are averaged to get the new downsampled value.
* **Bicubic (Bicubic Downsampling to):** Bicubic interpolation is used on a group of samples to get a new downsampled value.
* **Subsample (Subsampling to):** The center sample from a group of samples is used as the new downsampled value.



16 changes: 16 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/colorimagefilter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: colorImageFilter
---

# ColorImageFilter

| Method Name | Argument Name | Argument Type |
| ---------------- | ------------- | ----------------------------------------- |
| colorImageFilter | filter | Mostafaznv\PdfOptimizer\Enums\ImageFilter |

Specifies the <mark style="color:red;">compression filter</mark> to be used for color images.&#x20;

Ignored if AutoFilterColorImages is true or EncodeColorImages is false.



Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
description: colorImageResolution
---

# ColorImageResolution

| Method Name | Argument Name | Argument Type |
| -------------------- | ------------- | ------------- |
| colorImageResolution | resolution | int |

Specifies the resolution to which downsampled color images are reduced; <mark style="color:red;">valid values are 9 to 2400 pixels per inch.</mark>



{% hint style="info" %}
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.
{% endhint %}



20 changes: 20 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/compatibilitylevel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
description: compatibilityLevel
---

# CompatibilityLevel

| Method Name | Argument Name | Argument Type |
| ------------------ | ------------------ | ------------------------------------------------ |
| compatibilityLevel | compatibilityLevel | Mostafaznv\PdfOptimizer\Enums\CompatibilityLevel |

The PDF version number: <mark style="color:red;">**1.2, 1.3, 1.4, 1.5, 1.6, or 1.7**</mark>



{% hint style="info" %}
Applications other than Distiller do not support saving files as PDF 1.2.
{% endhint %}



14 changes: 14 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/compressfonts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
description: compressFonts
---

# CompressFonts

| Method Name | Argument Name | Argument Type |
| ------------- | ------------- | ------------- |
| compressFonts | status | bool |

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.



16 changes: 16 additions & 0 deletions docs/advanced-usage/configuring-ghostscript/compresspages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: compressPages
---

# CompressPages

| Method Name | Argument Name | Argument Type |
| ------------- | ------------- | ------------- |
| compressPages | status | boolean |

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.

InDesign also compresses ICC profiles, OutputIntentProfile and shading streams.



Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
description: convertCmykImagesToRGB
---

# ConvertCMYKImagesToRGB



| Method Name | Argument Name | Argument Type |
| ---------------------- | ------------- | ------------- |
| convertCmykImagesToRGB | status | boolean |



Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
description: defaultRenderingIntent
---

# DefaultRenderingIntent

| Method Name | Argument Name | Argument Type |
| ---------------------- | --------------- | ---------------------------------------------------- |
| defaultRenderingIntent | renderingIntent | Mostafaznv\PdfOptimizer\Enums\DefaultRenderingIntent |

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.



Loading

0 comments on commit ab61ca1

Please sign in to comment.