From 59adeaddffb187f09e731f995d5c5472fd30ac14 Mon Sep 17 00:00:00 2001 From: Mostafa Zeinivand Date: Fri, 12 Jan 2024 17:05:38 +0000 Subject: [PATCH 1/6] GITBOOK-2: No subject --- docs/README.md | 24 +++ docs/SUMMARY.md | 81 +++++++ .../configuring-ghostscript/README.md | 8 + .../ascii85encodepages.md | 20 ++ .../autofiltercolorimages.md | 22 ++ .../autofiltergrayimages.md | 22 ++ .../autorotatepages.md | 16 ++ .../colorconversionstrategy.md | 14 ++ .../colorimagedepth.md | 21 ++ .../colorimagedownsamplethreshold.md | 20 ++ .../colorimagedownsampletype.md | 18 ++ .../colorimagefilter.md | 16 ++ .../colorimageresolution.md | 20 ++ .../compatibilitylevel.md | 20 ++ .../configuring-ghostscript/compressfonts.md | 14 ++ .../configuring-ghostscript/compresspages.md | 16 ++ .../convertcmykimagestorgb.md | 14 ++ .../defaultrenderingintent.md | 14 ++ .../detectduplicateimages.md | 24 +++ .../downsamplecolorimages.md | 16 ++ .../downsamplegrayimages.md | 16 ++ .../downsamplemonoimages.md | 16 ++ .../configuring-ghostscript/embedallfonts.md | 17 ++ .../encodecolorimages.md | 16 ++ .../encodegrayimages.md | 16 ++ .../encodemonoimages.md | 16 ++ .../configuring-ghostscript/fastwebview.md | 22 ++ .../configuring-ghostscript/grayimagedepth.md | 17 ++ .../grayimagedownsamplethreshold.md | 14 ++ .../grayimagedownsampletype.md | 18 ++ .../grayimagefilter.md | 14 ++ .../grayimageresolution.md | 16 ++ .../lockdistillerparams.md | 18 ++ .../maxinlineimagesize.md | 22 ++ .../configuring-ghostscript/maxsubsetpct.md | 20 ++ .../configuring-ghostscript/monoimagedepth.md | 22 ++ .../monoimagedownsamplethreshold.md | 14 ++ .../monoimagedownsampletype.md | 18 ++ .../monoimagefilter.md | 18 ++ .../monoimageresolution.md | 16 ++ .../parsedsccomments.md | 16 ++ .../parsedsccommentsfordocinfo.md | 14 ++ .../passthroughjpegimages.md | 30 +++ .../passthroughjpximages.md | 20 ++ .../configuring-ghostscript/pdfa.md | 14 ++ .../pdfacompatibilitypolicy.md | 18 ++ .../configuring-ghostscript/pdfsettings.md | 30 +++ .../configuring-ghostscript/pdfx.md | 14 ++ .../preserveepsinfo.md | 14 ++ .../preservehalftoneinfo.md | 16 ++ .../preservemarkedcontent.md | 14 ++ .../preserveopicomments.md | 22 ++ .../preserveoverprintsettings.md | 16 ++ .../processcolormodel.md | 20 ++ .../configuring-ghostscript/subsetfonts.md | 16 ++ .../configuring-ghostscript/ucrandbginfo.md | 12 ++ .../useflatecompression.md | 14 ++ .../custom-ghostscript-options.md | 35 +++ docs/advanced-usage/export-script.md | 116 ++++++++++ .../ghostscript-binary-configuration.md | 38 ++++ docs/advanced-usage/logger.md | 32 +++ docs/advanced-usage/timeout.md | 30 +++ docs/basic-usage/laravel.md | 22 ++ docs/basic-usage/standalone-php.md | 35 +++ docs/getting-started/installation.md | 66 ++++++ docs/getting-started/license.md | 4 + docs/getting-started/support-us.md | 14 ++ docs/laravel-deep-dive/filesystem.md | 203 ++++++++++++++++++ docs/laravel-deep-dive/queue.md | 139 ++++++++++++ 69 files changed, 1800 insertions(+) create mode 100644 docs/README.md create mode 100644 docs/SUMMARY.md create mode 100644 docs/advanced-usage/configuring-ghostscript/README.md create mode 100644 docs/advanced-usage/configuring-ghostscript/ascii85encodepages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/autofiltercolorimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/autofiltergrayimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/autorotatepages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/colorconversionstrategy.md create mode 100644 docs/advanced-usage/configuring-ghostscript/colorimagedepth.md create mode 100644 docs/advanced-usage/configuring-ghostscript/colorimagedownsamplethreshold.md create mode 100644 docs/advanced-usage/configuring-ghostscript/colorimagedownsampletype.md create mode 100644 docs/advanced-usage/configuring-ghostscript/colorimagefilter.md create mode 100644 docs/advanced-usage/configuring-ghostscript/colorimageresolution.md create mode 100644 docs/advanced-usage/configuring-ghostscript/compatibilitylevel.md create mode 100644 docs/advanced-usage/configuring-ghostscript/compressfonts.md create mode 100644 docs/advanced-usage/configuring-ghostscript/compresspages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/convertcmykimagestorgb.md create mode 100644 docs/advanced-usage/configuring-ghostscript/defaultrenderingintent.md create mode 100644 docs/advanced-usage/configuring-ghostscript/detectduplicateimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/downsamplecolorimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/downsamplegrayimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/downsamplemonoimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/embedallfonts.md create mode 100644 docs/advanced-usage/configuring-ghostscript/encodecolorimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/encodegrayimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/encodemonoimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/fastwebview.md create mode 100644 docs/advanced-usage/configuring-ghostscript/grayimagedepth.md create mode 100644 docs/advanced-usage/configuring-ghostscript/grayimagedownsamplethreshold.md create mode 100644 docs/advanced-usage/configuring-ghostscript/grayimagedownsampletype.md create mode 100644 docs/advanced-usage/configuring-ghostscript/grayimagefilter.md create mode 100644 docs/advanced-usage/configuring-ghostscript/grayimageresolution.md create mode 100644 docs/advanced-usage/configuring-ghostscript/lockdistillerparams.md create mode 100644 docs/advanced-usage/configuring-ghostscript/maxinlineimagesize.md create mode 100644 docs/advanced-usage/configuring-ghostscript/maxsubsetpct.md create mode 100644 docs/advanced-usage/configuring-ghostscript/monoimagedepth.md create mode 100644 docs/advanced-usage/configuring-ghostscript/monoimagedownsamplethreshold.md create mode 100644 docs/advanced-usage/configuring-ghostscript/monoimagedownsampletype.md create mode 100644 docs/advanced-usage/configuring-ghostscript/monoimagefilter.md create mode 100644 docs/advanced-usage/configuring-ghostscript/monoimageresolution.md create mode 100644 docs/advanced-usage/configuring-ghostscript/parsedsccomments.md create mode 100644 docs/advanced-usage/configuring-ghostscript/parsedsccommentsfordocinfo.md create mode 100644 docs/advanced-usage/configuring-ghostscript/passthroughjpegimages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/passthroughjpximages.md create mode 100644 docs/advanced-usage/configuring-ghostscript/pdfa.md create mode 100644 docs/advanced-usage/configuring-ghostscript/pdfacompatibilitypolicy.md create mode 100644 docs/advanced-usage/configuring-ghostscript/pdfsettings.md create mode 100644 docs/advanced-usage/configuring-ghostscript/pdfx.md create mode 100644 docs/advanced-usage/configuring-ghostscript/preserveepsinfo.md create mode 100644 docs/advanced-usage/configuring-ghostscript/preservehalftoneinfo.md create mode 100644 docs/advanced-usage/configuring-ghostscript/preservemarkedcontent.md create mode 100644 docs/advanced-usage/configuring-ghostscript/preserveopicomments.md create mode 100644 docs/advanced-usage/configuring-ghostscript/preserveoverprintsettings.md create mode 100644 docs/advanced-usage/configuring-ghostscript/processcolormodel.md create mode 100644 docs/advanced-usage/configuring-ghostscript/subsetfonts.md create mode 100644 docs/advanced-usage/configuring-ghostscript/ucrandbginfo.md create mode 100644 docs/advanced-usage/configuring-ghostscript/useflatecompression.md create mode 100644 docs/advanced-usage/custom-ghostscript-options.md create mode 100644 docs/advanced-usage/export-script.md create mode 100644 docs/advanced-usage/ghostscript-binary-configuration.md create mode 100644 docs/advanced-usage/logger.md create mode 100644 docs/advanced-usage/timeout.md create mode 100644 docs/basic-usage/laravel.md create mode 100644 docs/basic-usage/standalone-php.md create mode 100644 docs/getting-started/installation.md create mode 100644 docs/getting-started/license.md create mode 100644 docs/getting-started/support-us.md create mode 100644 docs/laravel-deep-dive/filesystem.md create mode 100644 docs/laravel-deep-dive/queue.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..3aa868c --- /dev/null +++ b/docs/README.md @@ -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 `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. + +[![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 `file`` ``paths`, `UploadedFile` instances, and `disk` 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. + + + diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 0000000..ac9edc7 --- /dev/null +++ b/docs/SUMMARY.md @@ -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) diff --git a/docs/advanced-usage/configuring-ghostscript/README.md b/docs/advanced-usage/configuring-ghostscript/README.md new file mode 100644 index 0000000..82507b9 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/README.md @@ -0,0 +1,8 @@ +# Configuring Ghostscript + +In this section, we dive into the various methods provided by `pdf-optimizer` 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. + + + + + diff --git a/docs/advanced-usage/configuring-ghostscript/ascii85encodepages.md b/docs/advanced-usage/configuring-ghostscript/ascii85encodepages.md new file mode 100644 index 0000000..5cdeefd --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/ascii85encodepages.md @@ -0,0 +1,20 @@ +--- +description: ascii85EncodePages +--- + +# ASCII85EncodePages + +| Method Name | Argument Name | Argument Type | +| ------------------ | ------------- | ------------- | +| ascii85EncodePages | status | boolean | + +If true, 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 false, 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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/autofiltercolorimages.md b/docs/advanced-usage/configuring-ghostscript/autofiltercolorimages.md new file mode 100644 index 0000000..e9b5a7e --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/autofiltercolorimages.md @@ -0,0 +1,22 @@ +--- +description: autoFilterColorImages +--- + +# AutoFilterColorImages + +| Method Name | Argument Name | Argument Type | +| --------------------- | ------------- | ------------- | +| autoFilterColorImages | status | boolean | + +If true, the compression filter for color images is chosen based on the properties of each image, in conjunction with the `ColorImageAutoFilterStrategy` setting. + +If false, all color sampled images are compressed using the filter specified by ColorImageFilter. + + + +{% hint style="info" %} +This setting is relevant only if EncodeColorImages is true. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/autofiltergrayimages.md b/docs/advanced-usage/configuring-ghostscript/autofiltergrayimages.md new file mode 100644 index 0000000..a43569e --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/autofiltergrayimages.md @@ -0,0 +1,22 @@ +--- +description: autoFilterGrayImages +--- + +# AutoFilterGrayImages + +| Method Name | Argument Name | Argument Type | +| -------------------- | ------------- | ------------- | +| autoFilterGrayImages | status | boolean | + +If true, the compression filter for gray images is chosen based on the properties of each image, in conjunction with the GrayImageAutoFilterStrategy setting. + +If false, all color sampled images are compressed using the filter specified by GrayImageFilter. + + + +{% hint style="info" %} +This setting is relevant only if EncodeGrayImages is true. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/autorotatepages.md b/docs/advanced-usage/configuring-ghostscript/autorotatepages.md new file mode 100644 index 0000000..1d75c5e --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/autorotatepages.md @@ -0,0 +1,16 @@ +--- +description: autoRotatePages +--- + +# AutoRotatePages + +
Method NameArgument NameArgument Type
autoRotatePagesmodeMostafaznv\PdfOptimizer\Enums\AutoRotatePages
+ +Allows Distiller to automatically orient (rotate) pages based on the predominant text orientation. autorotation is not done if the file contains the %%ViewingOrientation DSC comment and ParseDSCComments is true. + +If AutoRotatePages is set to None, pages are not automatically oriented and the %%ViewingOrientation DSC comment is ignored. + + + + + diff --git a/docs/advanced-usage/configuring-ghostscript/colorconversionstrategy.md b/docs/advanced-usage/configuring-ghostscript/colorconversionstrategy.md new file mode 100644 index 0000000..f57b701 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/colorconversionstrategy.md @@ -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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/colorimagedepth.md b/docs/advanced-usage/configuring-ghostscript/colorimagedepth.md new file mode 100644 index 0000000..53b6af9 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/colorimagedepth.md @@ -0,0 +1,21 @@ +--- +description: colorImageDepth +--- + +# ColorImageDepth + +| Method Name | Argument Name | Argument Type | +| --------------- | ------------- | ---------------------------------------- | +| colorImageDepth | depth | Mostafaznv\PdfOptimizer\Enums\ImageDepth | + +Specifies the number of bits per color 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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/colorimagedownsamplethreshold.md b/docs/advanced-usage/configuring-ghostscript/colorimagedownsamplethreshold.md new file mode 100644 index 0000000..6c3c54b --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/colorimagedownsamplethreshold.md @@ -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. Must be between 1.0 through 10.0, inclusive. + + + +{% hint style="info" %} +If you set the threshold out of range, it reverts to a default of 1.5 +{% endhint %} + diff --git a/docs/advanced-usage/configuring-ghostscript/colorimagedownsampletype.md b/docs/advanced-usage/configuring-ghostscript/colorimagedownsampletype.md new file mode 100644 index 0000000..3045da6 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/colorimagedownsampletype.md @@ -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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/colorimagefilter.md b/docs/advanced-usage/configuring-ghostscript/colorimagefilter.md new file mode 100644 index 0000000..217712e --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/colorimagefilter.md @@ -0,0 +1,16 @@ +--- +description: colorImageFilter +--- + +# ColorImageFilter + +| Method Name | Argument Name | Argument Type | +| ---------------- | ------------- | ----------------------------------------- | +| colorImageFilter | filter | Mostafaznv\PdfOptimizer\Enums\ImageFilter | + +Specifies the compression filter to be used for color images. + +Ignored if AutoFilterColorImages is true or EncodeColorImages is false. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/colorimageresolution.md b/docs/advanced-usage/configuring-ghostscript/colorimageresolution.md new file mode 100644 index 0000000..57cf3a2 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/colorimageresolution.md @@ -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; valid values are 9 to 2400 pixels per inch. + + + +{% 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 %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/compatibilitylevel.md b/docs/advanced-usage/configuring-ghostscript/compatibilitylevel.md new file mode 100644 index 0000000..87d9e9a --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/compatibilitylevel.md @@ -0,0 +1,20 @@ +--- +description: compatibilityLevel +--- + +# CompatibilityLevel + +| Method Name | Argument Name | Argument Type | +| ------------------ | ------------------ | ------------------------------------------------ | +| compatibilityLevel | compatibilityLevel | Mostafaznv\PdfOptimizer\Enums\CompatibilityLevel | + +The PDF version number: **1.2, 1.3, 1.4, 1.5, 1.6, or 1.7** + + + +{% hint style="info" %} +Applications other than Distiller do not support saving files as PDF 1.2. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/compressfonts.md b/docs/advanced-usage/configuring-ghostscript/compressfonts.md new file mode 100644 index 0000000..e377e43 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/compressfonts.md @@ -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. The default value is true; the false setting is intended only for debugging as it will result in larger output. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/compresspages.md b/docs/advanced-usage/configuring-ghostscript/compresspages.md new file mode 100644 index 0000000..7f05298 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/compresspages.md @@ -0,0 +1,16 @@ +--- +description: compressPages +--- + +# CompressPages + +| Method Name | Argument Name | Argument Type | +| ------------- | ------------- | ------------- | +| compressPages | status | boolean | + +If true, 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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/convertcmykimagestorgb.md b/docs/advanced-usage/configuring-ghostscript/convertcmykimagestorgb.md new file mode 100644 index 0000000..df639ba --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/convertcmykimagestorgb.md @@ -0,0 +1,14 @@ +--- +description: convertCmykImagesToRGB +--- + +# ConvertCMYKImagesToRGB + + + +| Method Name | Argument Name | Argument Type | +| ---------------------- | ------------- | ------------- | +| convertCmykImagesToRGB | status | boolean | + + + diff --git a/docs/advanced-usage/configuring-ghostscript/defaultrenderingintent.md b/docs/advanced-usage/configuring-ghostscript/defaultrenderingintent.md new file mode 100644 index 0000000..475f880 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/defaultrenderingintent.md @@ -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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/detectduplicateimages.md b/docs/advanced-usage/configuring-ghostscript/detectduplicateimages.md new file mode 100644 index 0000000..f8f64c9 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/detectduplicateimages.md @@ -0,0 +1,24 @@ +--- +description: detectDuplicateImages +--- + +# DetectDuplicateImages + +| Method Name | Argument Name | Argument Type | +| --------------------- | ------------- | ------------- | +| detectDuplicateImages | status | boolean | + +Takes a Boolean argument, when set to true (the default) pdfwrite will compare all new images with all the images encountered to date (NOT small images which are stored in-line) to see if the new image is a duplicate of an earlier one. + +If it is a duplicate then instead of writing a new image into the PDF file, the PDF will reuse the reference to the earlier image. This can considerably reduce the size of the output PDF file, but increases the time taken to process the file. + +This time grows exponentially as more images are added, and on large input files with numerous images can be prohibitively slow. + + + +{% hint style="info" %} +Setting this to false will improve performance at the cost of final file size. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/downsamplecolorimages.md b/docs/advanced-usage/configuring-ghostscript/downsamplecolorimages.md new file mode 100644 index 0000000..e660be5 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/downsamplecolorimages.md @@ -0,0 +1,16 @@ +--- +description: downSampleColorImages +--- + +# DownsampleColorImages + +| Method Name | Argument Name | Argument Type | +| --------------------- | ------------- | ------------- | +| downSampleColorImages | status | boolean | + +If true, color images are downsampled using the resolution specified by ColorImageResolution, assuming the threshold specified by ColorImageDownsampleThreshold is met. + +If false, downsampling is not done and the resolution of color images in the PDF file is the same as the source images. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/downsamplegrayimages.md b/docs/advanced-usage/configuring-ghostscript/downsamplegrayimages.md new file mode 100644 index 0000000..edd2b60 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/downsamplegrayimages.md @@ -0,0 +1,16 @@ +--- +description: downSampleGrayImages +--- + +# DownsampleGrayImages + +| Method Name | Argument Name | Argument Type | +| -------------------- | ------------- | ------------- | +| downSampleGrayImages | status | boolean | + +If true, grayscale images are downsampled using the resolution specified by GrayImageResolution. + +If false, downsampling does not occur, and the resolution of grayscale images in the PDF file is the same as the source images. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/downsamplemonoimages.md b/docs/advanced-usage/configuring-ghostscript/downsamplemonoimages.md new file mode 100644 index 0000000..c6f5586 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/downsamplemonoimages.md @@ -0,0 +1,16 @@ +--- +description: downSampleMonoImages +--- + +# DownsampleMonoImages + +| Method Name | Argument Name | Argument Type | +| -------------------- | ------------- | ------------- | +| downSampleMonoImages | status | boolean | + +If true, monochrome images are downsampled using the resolution specified by MonoImageResolution. + +If false, downsampling is not done and the resolution of monochrome images in the PDF file is the same as the source images. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/embedallfonts.md b/docs/advanced-usage/configuring-ghostscript/embedallfonts.md new file mode 100644 index 0000000..9b57a5d --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/embedallfonts.md @@ -0,0 +1,17 @@ +--- +description: embedAllFonts +--- + +# EmbedAllFonts + +| Method Name | Argument Name | Argument Type | +| ------------- | ------------- | ------------- | +| embedAllFonts | status | boolean | + +If true, all fonts that have correct permissions are embedded in the PDF file; if false, they are not embedded: + +* Creative Suite applications automatically embed fonts. +* Distiller never embeds fonts in its NeverEmbed list even if this setting is true. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/encodecolorimages.md b/docs/advanced-usage/configuring-ghostscript/encodecolorimages.md new file mode 100644 index 0000000..e956a92 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/encodecolorimages.md @@ -0,0 +1,16 @@ +--- +description: encodeColorImages +--- + +# EncodeColorImages + +| Method Name | Argument Name | Argument Type | +| ----------------- | ------------- | ------------- | +| encodeColorImages | status | boolean | + +If true, color images are encoded using the compression filter specified by the value of ColorImageFilter. + +If false, compression filters are not applied to color images. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/encodegrayimages.md b/docs/advanced-usage/configuring-ghostscript/encodegrayimages.md new file mode 100644 index 0000000..55180d5 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/encodegrayimages.md @@ -0,0 +1,16 @@ +--- +description: encodeGrayImages +--- + +# EncodeGrayImages + +| Method Name | Argument Name | Argument Type | +| ---------------- | ------------- | ------------- | +| encodeGrayImages | status | boolean | + +If true, grayscale images are encoded using the compression filter specified by the value of GrayImageFilter. + +If false, compression filters are not applied to grayscale sampled images. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/encodemonoimages.md b/docs/advanced-usage/configuring-ghostscript/encodemonoimages.md new file mode 100644 index 0000000..ad98fac --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/encodemonoimages.md @@ -0,0 +1,16 @@ +--- +description: encodeMonoImages +--- + +# EncodeMonoImages + +| Method Name | Argument Name | Argument Type | +| ---------------- | ------------- | ------------- | +| encodeMonoImages | status | boolean | + +If true, monochrome images are encoded using the compression filter specified by the value of MonoImageFilter. + +If false, no compression filters are applied to monochrome images. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/fastwebview.md b/docs/advanced-usage/configuring-ghostscript/fastwebview.md new file mode 100644 index 0000000..b45c001 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/fastwebview.md @@ -0,0 +1,22 @@ +--- +description: fastWebView +--- + +# FastWebView + +| Method Name | Argument Name | Argument Type | +| ----------- | ------------- | ------------- | +| fastWebView | status | boolean | + +Takes a Boolean argument, default is false. + +When set to true pdfwrite will reorder the output PDF file to conform to the Adobe ‘linearised’ PDF specification. The Acrobat user interface refers to this as Optimised for Fast Web Viewing. + + + +{% hint style="info" %} +Note that this will cause the conversion to PDF to be slightly slower and will usually result in a slightly larger PDF file. This option is incompatible with producing an encrypted (password protected) PDF file. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/grayimagedepth.md b/docs/advanced-usage/configuring-ghostscript/grayimagedepth.md new file mode 100644 index 0000000..fdb39c2 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/grayimagedepth.md @@ -0,0 +1,17 @@ +--- +description: grayImageDepth +--- + +# GrayImageDepth + +| Method Name | Argument Name | Argument Type | +| -------------- | ------------- | ---------------------------------------- | +| grayImageDepth | depth | Mostafaznv\PdfOptimizer\Enums\ImageDepth | + +Specifies the number of bits per sample in the image. The following values are valid: + +* 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 sample as the original image + + + diff --git a/docs/advanced-usage/configuring-ghostscript/grayimagedownsamplethreshold.md b/docs/advanced-usage/configuring-ghostscript/grayimagedownsamplethreshold.md new file mode 100644 index 0000000..c0a64a2 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/grayimagedownsamplethreshold.md @@ -0,0 +1,14 @@ +--- +description: grayImageDownSampleThreshold +--- + +# GrayImageDownsampleThreshold + +| Method Name | Argument Name | Argument Type | +| ---------------------------- | ------------- | ------------- | +| grayImageDownSampleThreshold | threshold | float | + +Sets the image downsample threshold for grayscale images. This is the ratio of image resolution to output resolution above which downsampling may be performed. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/grayimagedownsampletype.md b/docs/advanced-usage/configuring-ghostscript/grayimagedownsampletype.md new file mode 100644 index 0000000..42354e9 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/grayimagedownsampletype.md @@ -0,0 +1,18 @@ +--- +description: grayImageDownSampleType +--- + +# GrayImageDownsampleType + +| Method Name | Argument Name | Argument Type | +| ----------------------- | ------------- | ----------------------------------------------------- | +| grayImageDownSampleType | type | Mostafaznv\PdfOptimizer\Enums\GrayImageDownSampleType | + +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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/grayimagefilter.md b/docs/advanced-usage/configuring-ghostscript/grayimagefilter.md new file mode 100644 index 0000000..1165885 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/grayimagefilter.md @@ -0,0 +1,14 @@ +--- +description: grayImageFilter +--- + +# GrayImageFilter + +| Method Name | Argument Name | Argument Type | +| --------------- | ------------- | ----------------------------------------- | +| grayImageFilter | filter | Mostafaznv\PdfOptimizer\Enums\ImageFilter | + +Specifies the compression filter to be used for grayscale images. Ignored if AutoFilterGrayImages is true or EncodeGrayImages is false. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/grayimageresolution.md b/docs/advanced-usage/configuring-ghostscript/grayimageresolution.md new file mode 100644 index 0000000..54d0e59 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/grayimageresolution.md @@ -0,0 +1,16 @@ +--- +description: grayImageResolution +--- + +# GrayImageResolution + +| Method Name | Argument Name | Argument Type | +| ------------------- | ------------- | ------------- | +| grayImageResolution | resolution | integer | + +Specifies the resolution to which downsampled gray images are reduced. + +Valid values are `9` to `2400` pixels per inch. A gray image is downsampled if DownsampleGrayImages is true and the resolution of the input image meets the criteria described in Downsampling and subsampling images. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/lockdistillerparams.md b/docs/advanced-usage/configuring-ghostscript/lockdistillerparams.md new file mode 100644 index 0000000..9dccdf2 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/lockdistillerparams.md @@ -0,0 +1,18 @@ +--- +description: lockDistillerParams +--- + +# LockDistillerParams + +| Method Name | Argument Name | Argument Type | +| ------------------- | ------------- | ------------- | +| lockDistillerParams | status | boolean | + +If true, Distiller ignores any settings specified by setdistillerparams operators in the incoming PostScript file and uses only those settings present in the Adobe PDF settings file (or their default values if not present). + +If false, any settings specified in the PostScript file override the initial settings. These settings are in effect for the duration of the current save level. + + + + + diff --git a/docs/advanced-usage/configuring-ghostscript/maxinlineimagesize.md b/docs/advanced-usage/configuring-ghostscript/maxinlineimagesize.md new file mode 100644 index 0000000..ec9a0d4 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/maxinlineimagesize.md @@ -0,0 +1,22 @@ +--- +description: maxInlineImageSize +--- + +# MaxInlineImageSize + +| Method Name | Argument Name | Argument Type | +| ------------------ | ------------- | ------------- | +| maxInlineImageSize | size | integer | + +Specifies the maximum size of an inline image, in bytes. For images larger than this size, pdfwrite will create an XObject instead of embedding the image into the context stream. + +The default value is 4000. + + + +{% hint style="info" %} +Note that redundant inline images must be embedded each time they occur in the document, while multiple references can be made to a single XObject image. Therefore, it may be advantageous to set a small or zero value if the source document is expected to contain multiple identical images, reducing the size of the generated PDF. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/maxsubsetpct.md b/docs/advanced-usage/configuring-ghostscript/maxsubsetpct.md new file mode 100644 index 0000000..56ee4b5 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/maxsubsetpct.md @@ -0,0 +1,20 @@ +--- +description: maxSubsetPct +--- + +# MaxSubsetPct + +| Method Name | Argument Name | Argument Type | +| ------------ | ------------- | ------------- | +| maxSubsetPct | max | integer | + +The maximum percentage of glyphs in a font that can be used before the entire font is embedded instead of a subset. + +The allowable range is 1 through 100. + + + +Distiller only uses this value if SubsetFonts is true. For example, a value of 30 means that a font will be embedded in full (not subset) if more than 30% of glyphs are used; a value of 100 means all fonts will be subset no matter how many glyphs are used (because you cannot use more than 100% of glyphs). + + + diff --git a/docs/advanced-usage/configuring-ghostscript/monoimagedepth.md b/docs/advanced-usage/configuring-ghostscript/monoimagedepth.md new file mode 100644 index 0000000..1d77a05 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/monoimagedepth.md @@ -0,0 +1,22 @@ +--- +description: monoImageDepth +--- + +# MonoImageDepth + +| Method Name | Argument Name | Argument Type | +| -------------- | ------------- | ---------------------------------------- | +| monoImageDepth | depth | Mostafaznv\PdfOptimizer\Enums\ImageDepth | + +Specifies the number of bits per sample in a downsampled image. Allowed values are: + +* The number of bits per sample: 1 , 2 , 4 , or 8 +* When the value is greater than 1, monochrome images are converted to grayscale images. +* -1 , which forces the downsampled image to have the same number of bits per sample as the original image. (For monochrome images, this is the same as a value of 1.) + + + +MonoImageDepth is not used unless DownsampleMonoImages and AntiAliasMonoImages are true. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/monoimagedownsamplethreshold.md b/docs/advanced-usage/configuring-ghostscript/monoimagedownsamplethreshold.md new file mode 100644 index 0000000..3b7da67 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/monoimagedownsamplethreshold.md @@ -0,0 +1,14 @@ +--- +description: monoImageDownSampleThreshold +--- + +# MonoImageDownsampleThreshold + +| Method Name | Argument Name | Argument Type | +| ---------------------------- | ------------- | ------------- | +| monoImageDownSampleThreshold | threshold | float | + +Sets the image downsample threshold for monochrome images. This is the ratio of image resolution to output resolution above which downsampling may be performed. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/monoimagedownsampletype.md b/docs/advanced-usage/configuring-ghostscript/monoimagedownsampletype.md new file mode 100644 index 0000000..f2aec13 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/monoimagedownsampletype.md @@ -0,0 +1,18 @@ +--- +description: monoImageDownSampleType +--- + +# MonoImageDownsampleType + +| Method Name | Argument Name | Argument Type | +| ----------------------- | ------------- | ----------------------------------------------------- | +| monoImageDownSampleType | type | Mostafaznv\PdfOptimizer\Enums\MonoImageDownSampleType | + +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. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/monoimagefilter.md b/docs/advanced-usage/configuring-ghostscript/monoimagefilter.md new file mode 100644 index 0000000..b98eaeb --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/monoimagefilter.md @@ -0,0 +1,18 @@ +--- +description: monoImageFilter +--- + +# MonoImageFilter + +| Method Name | Argument Name | Argument Type | +| --------------- | ------------- | --------------------------------------------- | +| monoImageFilter | filter | Mostafaznv\PdfOptimizer\Enums\MonoImageFilter | + +Specifies the compression filter to be used for monochrome images. Must be one of the following values: + +* **CCITTFaxEncode:** Selects CCITT Group 3 or 4 facsimile encoding +* **FlateEncode:** Selects Flate (ZIP) compression +* **RunLengthEncode:** Selects run length encoding + + + diff --git a/docs/advanced-usage/configuring-ghostscript/monoimageresolution.md b/docs/advanced-usage/configuring-ghostscript/monoimageresolution.md new file mode 100644 index 0000000..57f5546 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/monoimageresolution.md @@ -0,0 +1,16 @@ +--- +description: monoImageResolution +--- + +# MonoImageResolution + +| Method Name | Argument Name | Argument Type | +| ------------------- | ------------- | ------------- | +| monoImageResolution | resolution | integer | + +Specifies the resolution to which downsampled monochrome images are reduced; valid values are 9 to 2400 pixels per inch. + +A monochrome image is downsampled if DownsampleMonoImages is true and the resolution of the input image meets the criteria + + + diff --git a/docs/advanced-usage/configuring-ghostscript/parsedsccomments.md b/docs/advanced-usage/configuring-ghostscript/parsedsccomments.md new file mode 100644 index 0000000..619291f --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/parsedsccomments.md @@ -0,0 +1,16 @@ +--- +description: parseDscComments +--- + +# ParseDSCComments + +| Method Name | Argument Name | Argument Type | +| ---------------- | ------------- | ------------- | +| parseDscComments | status | boolean | + +If true, Distiller parses the DSC comments for any information that might be helpful for distilling the file or for information that is passed into the PDF file. + +If false, Distiller treats the DSC comments as pure PostScript comments and ignores them. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/parsedsccommentsfordocinfo.md b/docs/advanced-usage/configuring-ghostscript/parsedsccommentsfordocinfo.md new file mode 100644 index 0000000..d347338 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/parsedsccommentsfordocinfo.md @@ -0,0 +1,14 @@ +--- +description: parseDscCommentsForDocInfo +--- + +# ParseDSCCommentsForDocInfo + +| Method Name | Argument Name | Argument Type | +| -------------------------- | ------------- | ------------- | +| parseDscCommentsForDocInfo | status | boolean | + +If true, Distiller attempts to preserve the Document Information from the PostScript DSC comments as properties of the PDF document. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/passthroughjpegimages.md b/docs/advanced-usage/configuring-ghostscript/passthroughjpegimages.md new file mode 100644 index 0000000..c4c0400 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/passthroughjpegimages.md @@ -0,0 +1,30 @@ +--- +description: passThroughJpegImages +--- + +# PassThroughJPEGImages + +| Method Name | Argument Name | Argument Type | +| --------------------- | ------------- | ------------- | +| passThroughJpegImages | status | boolean | + +If true, JPEG images (images that are already compressed with the DCTEncode filter) are `passed through` Distiller without re-compressing them. (Distiller does perform a decompression to ensure that images are not corrupt, but then passes the original compressed image to the PDF file.) Images that are not compressed will still be compressed according to the image settings in effect for the type of image (for example, ColorImageFilter , etc.). + +If false, all JPEG encoded images are decompressed and recompressed according the compression settings in effect. + + + +{% hint style="info" %} +However, that JPEG images that meet the following criteria are not passed through even if the value of PassThroughJPEGImages is true: + + + +* The image will be downsampled. +* ColorConversionStrategy is sRGB and the current PostScript color space (for the image) is not DeviceRGB or DeviceGray. +* The image will be cropped—i.e., the clip path is such that more than 10% of the image pixels will be removed. +{% endhint %} + +Creative Suite applications do not use this setting. However, Illustrator and InDesign normally behave as if it were true with regard to placed PDF files containing compressed images. That is, they do not normally uncompress and recompress them, unless color conversion or downsampling takes place. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/passthroughjpximages.md b/docs/advanced-usage/configuring-ghostscript/passthroughjpximages.md new file mode 100644 index 0000000..1c049f1 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/passthroughjpximages.md @@ -0,0 +1,20 @@ +--- +description: passThroughJpxImages +--- + +# PassThroughJPXImages + +| Method Name | Argument Name | Argument Type | +| -------------------- | ------------- | ------------- | +| passThroughJpxImages | status | boolean | + +When true image data in the source which is encoded using the JPX (JPEG 2000) filter will not be decompressed and then recompressed on output. This prevents the multiplication of JPEG artefacts caused by lossy compression. PassThroughJPXImages currently only affects simple JPX encoded images. It has no effect on JPEG encoded images (see above) or masked images. + +In addition, this parameter will be ignored if the pdfwrite device needs to modify the source data. This can happen if the image is being downsampled, changing colour space or having transfer functions applied. + +Note that this parameter essentially overrides the EncodeColorImages and EncodeGrayImages parameters if they are false, the image will still be written with a JPXDecode filter. NB this feature currently only works with PostScript or PDF input, it does not work with PCL, PXL or XPS input. + + + + + diff --git a/docs/advanced-usage/configuring-ghostscript/pdfa.md b/docs/advanced-usage/configuring-ghostscript/pdfa.md new file mode 100644 index 0000000..e9076a9 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/pdfa.md @@ -0,0 +1,14 @@ +--- +description: pdfA +--- + +# PDFA + +| Method Name | Argument Name | Argument Type | +| ----------- | ------------- | ------------- | +| pdfA | version | int | + +Specify the -dPDFA option to specify PDF/A-1, -dPDFA=2 for PDF/A-2 or -dPDFA=3 for PDF/A-3. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/pdfacompatibilitypolicy.md b/docs/advanced-usage/configuring-ghostscript/pdfacompatibilitypolicy.md new file mode 100644 index 0000000..dc9c774 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/pdfacompatibilitypolicy.md @@ -0,0 +1,18 @@ +--- +description: pdfACompatibilityPolicy +--- + +# PDFACompatibilityPolicy + +| Method Name | Argument Name | Argument Type | +| ----------------------- | ------------- | ------------- | +| pdfACompatibilityPolicy | policy | int | + +When an operation (e.g. pdfmark) is encountered which cannot be emitted in a PDF/A compliant file, this policy is consulted, there are currently three possible values: + +* **0:** (default) Include the feature or operation in the output file, the file will not be PDF/A compliant. Because the document Catalog is emitted before this is encountered, the file will still contain PDF/A metadata but will not be compliant. A warning will be emitted in this case. +* **1:** The feature or operation is ignored, the resulting PDF file will be PDF/A compliant. A warning will be emitted for every elided feature. +* **2:** Processing of the file is aborted with an error, the exact error may vary depending on the nature of the PDF/A incompatibility. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/pdfsettings.md b/docs/advanced-usage/configuring-ghostscript/pdfsettings.md new file mode 100644 index 0000000..982d6b5 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/pdfsettings.md @@ -0,0 +1,30 @@ +--- +description: settings +--- + +# PDFSETTINGS + +| Method Name | Argument Name | Argument Type | +| ----------- | ------------- | ----------------------------------------- | +| settings | settings | Mostafaznv\PdfOptimizer\Enums\PdfSettings | + +Presets the `distiller parameters` to one of the following predefined settings: + +* `/screen` selects low-resolution output similar to the Acrobat Distiller **Screen Optimized** setting. +* `/ebook` selects medium-resolution output similar to the Acrobat Distiller **eBook** setting. +* `/printer` selects output similar to the Acrobat Distiller **Print Optimized** setting. +* `/prepress` selects output similar to Acrobat Distiller **Prepress Optimized** setting. +* `/default` selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file. + + + +{% hint style="info" %} +Please be aware that the `/prepress` setting does not indicate the highest quality conversion. Using any of these presets will involve altering the input, and as such may result in a PDF of poorer quality (compared to the input) than simply using the defaults. The ‘best’ quality (where best means closest to the original input) is obtained by not setting this parameter at all (or by using /default). +{% endhint %} + + + +The `PDFSETTINGS` presets should only be used if you are sure you understand that the output will be altered in a variety of ways from the input. It is usually better to adjust the controls individually if you have a genuine requirement to produce, for example, a PDF file where the images are reduced in resolution. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/pdfx.md b/docs/advanced-usage/configuring-ghostscript/pdfx.md new file mode 100644 index 0000000..e6b434a --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/pdfx.md @@ -0,0 +1,14 @@ +--- +description: pdfX +--- + +# PDFX + +| Method Name | Argument Name | Argument Type | +| ----------- | ------------- | ------------- | +| pdfX | status | boolean | + +Specify the -dPDFX option. It provides the document conformity and forces -dCompatibilityLevel=1.3 + + + diff --git a/docs/advanced-usage/configuring-ghostscript/preserveepsinfo.md b/docs/advanced-usage/configuring-ghostscript/preserveepsinfo.md new file mode 100644 index 0000000..7d9a231 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/preserveepsinfo.md @@ -0,0 +1,14 @@ +--- +description: preserveEpsInfo +--- + +# PreserveEPSInfo + +| Method Name | Argument Name | Argument Type | +| --------------- | ------------- | ------------- | +| preserveEpsInfo | status | boolean | + +If true, and ParseDSCComments is true, Distiller attempts to preserve the encapsulated PostScript (EPS) information in the PostScript file as properties of the resulting PDF file. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/preservehalftoneinfo.md b/docs/advanced-usage/configuring-ghostscript/preservehalftoneinfo.md new file mode 100644 index 0000000..f7902bf --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/preservehalftoneinfo.md @@ -0,0 +1,16 @@ +--- +description: preserveHalftoneInfo +--- + +# PreserveHalftoneInfo + +| Method Name | Argument Name | Argument Type | +| -------------------- | ------------- | ------------- | +| preserveHalftoneInfo | status | bool | + +If true, Distiller passes halftone screen information (frequency, angle, and spot function) into the PDF file. + +If false, halftone information is not passed in. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/preservemarkedcontent.md b/docs/advanced-usage/configuring-ghostscript/preservemarkedcontent.md new file mode 100644 index 0000000..a7e074e --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/preservemarkedcontent.md @@ -0,0 +1,14 @@ +--- +description: preserveMarkedContent +--- + +# PreserveMarkedContent + +| Method Name | Argument Name | Argument Type | +| --------------------- | ------------- | ------------- | +| preserveMarkedContent | status | boolean | + +We now attempt to preserve marked content from input PDF files through to the output PDF file (note, not in output PostScript!) This does not include marked content relating to optional content, because currently we do not preserve optional content, it is instead applied by the interpreter. This control also requires the PDF interpreter to pass the marked content to the pdfwrite device, this is only done with the new (C-based) PDF interpreter. The old (PostScript-based) interpreter does not support this feature and will not pass marked content to the pdfwrite device. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/preserveopicomments.md b/docs/advanced-usage/configuring-ghostscript/preserveopicomments.md new file mode 100644 index 0000000..5caa14e --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/preserveopicomments.md @@ -0,0 +1,22 @@ +--- +description: preserveOpiComments +--- + +# PreserveOPIComments + +| Method Name | Argument Name | Argument Type | +| ------------------- | ------------- | ------------- | +| preserveOpiComments | status | boolean | + +If true, Distiller places the page contents within a set of Open Prepress Interface(OPI) comments in a Form XObject dictionary and preserves the OPI comment information in an OPI dictionary attached to the Form. Page contents data within a set of OPI comments may include proxy images, high-resolution images, or nothing. + +If PreserveOPIComments is false, Distiller ignores OPI comments and their page contents. Setting PreserveOPIComments to false results in slightly simpler and smaller PDF files. Doing so is acceptable when use of an OPI server is not anticipated. + + + +{% hint style="info" %} +Distiller ignores PreserveOPIComments if ParseDSCComments is false. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/preserveoverprintsettings.md b/docs/advanced-usage/configuring-ghostscript/preserveoverprintsettings.md new file mode 100644 index 0000000..93a7bcd --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/preserveoverprintsettings.md @@ -0,0 +1,16 @@ +--- +description: preserveOverprintSettings +--- + +# PreserveOverprintSettings + +| Method Name | Argument Name | Argument Type | +| ------------------------- | ------------- | ------------- | +| preserveOverprintSettings | status | boolean | + +If true, Distiller passes the value of the setoverprint operator through to the PDF file. + +If false, overprint is ignored (the information is not passed). + + + diff --git a/docs/advanced-usage/configuring-ghostscript/processcolormodel.md b/docs/advanced-usage/configuring-ghostscript/processcolormodel.md new file mode 100644 index 0000000..b423d36 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/processcolormodel.md @@ -0,0 +1,20 @@ +--- +description: processColorModel +--- + +# ProcessColorModel + +| Method Name | Argument Name | Argument Type | +| ----------------- | ------------- | ----------------------------------------------- | +| processColorModel | model | Mostafaznv\PdfOptimizer\Enums\ProcessColorModel | + +A symbol taken from /DeviceGray, /DeviceRGB or /DeviceCMYK which can be used to select 1, 3 or 4 colors respectively. + + + +{% hint style="info" %} +Note that this parameter takes precedence over Colors, and that both affect the same variable of the driver. +{% endhint %} + + + diff --git a/docs/advanced-usage/configuring-ghostscript/subsetfonts.md b/docs/advanced-usage/configuring-ghostscript/subsetfonts.md new file mode 100644 index 0000000..fb8d742 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/subsetfonts.md @@ -0,0 +1,16 @@ +--- +description: subsetFonts +--- + +# SubsetFonts + +| Method Name | Argument Name | Argument Type | +| ----------- | ------------- | ------------- | +| subsetFonts | status | boolean | + +If true, font subsetting is enabled. + +If false, subsetting is not enabled. Font subsetting embeds only those glyphs that are used in a document, instead of the entire font. This reduces the size of a PDF file that contains embedded fonts. If font subsetting is enabled, the application determines whether to embed the entire font or a subset by the number of glyphs in the font that are used (including component glyphs referenced by `seac` glyphs), and the value of `MaxSubsetPct`. + + + diff --git a/docs/advanced-usage/configuring-ghostscript/ucrandbginfo.md b/docs/advanced-usage/configuring-ghostscript/ucrandbginfo.md new file mode 100644 index 0000000..5a03381 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/ucrandbginfo.md @@ -0,0 +1,12 @@ +--- +description: ucRandBbInfo +--- + +# UCRandBGInfo + +| Method Name | Argument Name | Argument Type | +| ------------ | ------------- | ------------------------------------------ | +| ucRandBbInfo | info | Mostafaznv\PdfOptimizer\Enums\UCRandBGInfo | + + + diff --git a/docs/advanced-usage/configuring-ghostscript/useflatecompression.md b/docs/advanced-usage/configuring-ghostscript/useflatecompression.md new file mode 100644 index 0000000..f39af71 --- /dev/null +++ b/docs/advanced-usage/configuring-ghostscript/useflatecompression.md @@ -0,0 +1,14 @@ +--- +description: useFlateCompression +--- + +# UseFlateCompression + +| Method Name | Argument Name | Argument Type | +| ------------------- | ------------- | ------------- | +| useFlateCompression | status | boolean | + +Because the LZW compression scheme was covered by patents at the time this device was created, pdfwrite does not actually use LZW compression: all requests for LZW compression are ignored. UseFlateCompression is treated as always on, but the switch CompressPages can be set too false to turn off page level stream compression. Now that the patent has expired, we could change this should it become worthwhile. + + + diff --git a/docs/advanced-usage/custom-ghostscript-options.md b/docs/advanced-usage/custom-ghostscript-options.md new file mode 100644 index 0000000..f2bf4b6 --- /dev/null +++ b/docs/advanced-usage/custom-ghostscript-options.md @@ -0,0 +1,35 @@ +# Custom Ghostscript Options + +For scenarios where the existing configuration options may not cover your specific needs, the `setExtraOptions` method allows you to inject custom Ghostscript options directly into the optimization script. This flexibility ensures that no aspect of the optimization process is beyond your control. + + + +{% tabs %} +{% tab title="Standalone PHP" %} +```php +use Mostafaznv\PdfOptimizer\PdfOptimizer; + + +PdfOptimizer::init() + ->setExtraOptions([ + '-dCustom1=true', + '-dCustom2=false' + ]) + ->optimize('input.pdf', 'output.pdf'); +``` +{% endtab %} + +{% tab title="Laravel" %} +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; + +PdfOptimizer::open('input-1.pdf') + ->setExtraOptions([ + '-dCustom1=true', + '-dCustom2=false' + ]) + ->optimize('output-1.pdf'); +``` +{% endtab %} +{% endtabs %} + diff --git a/docs/advanced-usage/export-script.md b/docs/advanced-usage/export-script.md new file mode 100644 index 0000000..be5afa0 --- /dev/null +++ b/docs/advanced-usage/export-script.md @@ -0,0 +1,116 @@ +# Export Script + +Retrieve the Ghostscript script generated by pdf-optimizer for external analysis or use. Choose between exportScriptAsString and exportScriptAsArray methods to obtain the script as a string or an array, respectively. + +Retrieve the Ghostscript script or command generated by pdf-optimizer for further analysis or external use. The methods exportScriptAsString and exportScriptAsArray provide options to obtain the Ghostscript script as a string or an array, respectively. + + + +### To Array + +{% tabs %} +{% tab title="Standalone PHP" %} +```php +use Mostafaznv\PdfOptimizer\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; + +# input file (optinal, could be null) +$input = 'path/to/large.pdf'; + +# output file (optinal, could be null) +$output = 'path/to/optimized.pdf'; + +# export script as array +$command = PdfOptimizer::init() + ->compressFonts() + ->colorImageResolution(60) + ->colorConversionStrategy(ColorConversionStrategy::GRAY) + ->command($input, $output); + + +var_dump($command); +``` +{% endtab %} + +{% tab title="Laravel" %} +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +# input file (optinal, could be null) +$input = 'input.pdf'; + +# output file (optinal, could be null) +$output = 'optimized.pdf'; + +# export script as array +$command = PdfOptimizer::open($input) + ->settings(PdfSettings::SCREEN) + ->colorConversionStrategy(ColorConversionStrategy::GRAY) + ->colorImageResolution(50) + ->command($input, $output); + + +dd($command); +``` +{% endtab %} +{% endtabs %} + +### To String + +{% tabs %} +{% tab title="Standalone PHP" %} +```php +use Mostafaznv\PdfOptimizer\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; + +# input file (optinal, could be null) +$input = 'path/to/large.pdf'; + +# output file (optinal, could be null) +$output = 'path/to/optimized.pdf'; + +# export script as array +$command = PdfOptimizer::init() + ->compressFonts() + ->colorImageResolution(60) + ->colorConversionStrategy(ColorConversionStrategy::GRAY) + ->toString($input, $output); + + +echo $command; +``` +{% endtab %} + +{% tab title="Laravel" %} +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +# input file (optinal, could be null) +$input = 'input.pdf'; + +# output file (optinal, could be null) +$output = 'optimized.pdf'; + +# export script as array +$command = PdfOptimizer::open($input) + ->settings(PdfSettings::SCREEN) + ->colorConversionStrategy(ColorConversionStrategy::GRAY) + ->colorImageResolution(50) + ->toString($input, $output); + + +dd($command); +``` +{% endtab %} +{% endtabs %} + + + +{% hint style="info" %} +Both the `command` and `toString` methods have optional parameters that allow for specifying the `input` and `output` file paths, providing a more personalized export. +{% endhint %} + diff --git a/docs/advanced-usage/ghostscript-binary-configuration.md b/docs/advanced-usage/ghostscript-binary-configuration.md new file mode 100644 index 0000000..74da545 --- /dev/null +++ b/docs/advanced-usage/ghostscript-binary-configuration.md @@ -0,0 +1,38 @@ +# Ghostscript Binary Configuration + +Customize the Ghostscript binary path used by pdf-optimizer to match your environment. This option provides flexibility in specifying the exact location of the Ghostscript binary on your server. + + + + + +{% tabs %} +{% tab title="Standalone PHP" %} +You can specify the exact path to the Ghostscript binary file by passing it to the `init` method of the `PdfOptimizer` class. + +```php +use Mostafaznv\PdfOptimizer\PdfOptimizer; + +PdfOptimizer::init('/path/to/gs')->optimize('input.pdf', 'output.pdf'); +``` +{% endtab %} + +{% tab title="Laravel" %} +You can specify the exact path to the Ghostscript binary file using the `setGsBinary` method of the `PdfOptimizer` class. + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; + +PdfOptimizer::fromDisk('files') + ->open('input-1.pdf') + ->setGsBinary('/usr/local/bin/gs') + ->toDisk('s3') + ->optimize('output-1.pdf'); +``` + + + +**Note:** The `setGsBinary` method must be called after the `fromDisk` and `open` methods. This option is specifically available during the exporting phase of the optimization process. +{% endtab %} +{% endtabs %} + diff --git a/docs/advanced-usage/logger.md b/docs/advanced-usage/logger.md new file mode 100644 index 0000000..b7ceba6 --- /dev/null +++ b/docs/advanced-usage/logger.md @@ -0,0 +1,32 @@ +# Logger + +Integrate a custom logger into the pdf-optimizer package using the `logger` method. This empowers you to capture detailed logs and gain insights into the optimization process, aiding in debugging and monitoring. + +A logger, is a class that implements `Psr\Log\LoggerInterface`, utilized for logging activities. A recommended logging library that fully complies with this interface is [Monolog](https://github.com/Seldaek/monolog). The pdf-optimizer package utilizes the logger to record information such as the Optimizers used, executed commands, and their respective outputs in the log files. + + + +{% tabs %} +{% tab title="Standalone PHP" %} +```php +use App\Logger; +use Mostafaznv\PdfOptimizer\PdfOptimizer; + +$logger = new Logger; + +PdfOptimizer::init()->logger($logger)->optimize('input.pdf', 'output.pdf'); +``` +{% endtab %} + +{% tab title="Laravel" %} +```php +use App\Logger; +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; + +PdfOptimizer::open('input-1.pdf') + ->logger(new Logger) + ->optimize('output-1.pdf'); +``` +{% endtab %} +{% endtabs %} + diff --git a/docs/advanced-usage/timeout.md b/docs/advanced-usage/timeout.md new file mode 100644 index 0000000..144a6a3 --- /dev/null +++ b/docs/advanced-usage/timeout.md @@ -0,0 +1,30 @@ +# Timeout + +Customize the timeout setting to exert control over the duration of the optimization process, allowing you to fine-tune the time allocated for the operation based on the specific requirements of your application or environment. + + + +{% tabs %} +{% tab title="Standalone PHP" %} +By default processes have a timeout of 300 seconds, however you can change it passing a different timeout (in seconds) to the `setTimeout` method: + +```php +use Mostafaznv\PdfOptimizer\PdfOptimizer; + +PdfOptimizer::init()->setTimeout(500)->optimize('input.pdf, 'output.pdf'); +``` +{% endtab %} + +{% tab title="Laravel" %} +By default, processes have a timeout of 300 seconds, which is set by `config('pdf-optimizer.timeout')`. However, you can modify this timeout by passing a different duration (in seconds) to the `setTimeout` method: + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; + +PdfOptimizer::open('input-1.pdf') + ->setTimeout(500) + ->optimize('output-1.pdf'); +``` +{% endtab %} +{% endtabs %} + diff --git a/docs/basic-usage/laravel.md b/docs/basic-usage/laravel.md new file mode 100644 index 0000000..f6a3699 --- /dev/null +++ b/docs/basic-usage/laravel.md @@ -0,0 +1,22 @@ +# Laravel + +Leveraging the pdf-optimizer package within your Laravel applications allows for seamless optimization and compression of PDF files. With the Laravel-specific features provided by PdfOptimizer, including support for disks, queues, and comprehensive settings, you can efficiently tailor the optimization process to your application's needs. + + + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$result = PdfOptimizer::fromDisk('local') + ->open('input-1.pdf') + ->toDisk('s3') + ->settings(PdfSettings::SCREEN) + ->colorConversionStrategy(ColorConversionStrategy::DEVICE_INDEPENDENT_COLOR) + ->colorImageResolution(50) + ->optimize('output-1.pdf'); + + +dd($result->status, $result->message); +``` diff --git a/docs/basic-usage/standalone-php.md b/docs/basic-usage/standalone-php.md new file mode 100644 index 0000000..63af2a1 --- /dev/null +++ b/docs/basic-usage/standalone-php.md @@ -0,0 +1,35 @@ +# Standalone PHP + +Optimizing and compressing PDF files in your PHP applications is a breeze with the PhpOptimizer class. This class provides a simple and effective way to enhance the performance of your PDFs while minimizing file sizes. + + + +```php +use Mostafaznv\PdfOptimizer\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + + +# input pdf file path +$file = 'path/to/large.pdf'; + +# output (optimized) pdf file path +$optimized = 'path/to/optimized.pdf'; + + +# optimizing the pdf file +$result = PdfOptimizer::init() + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(60) + ->colorConversionStrategy(ColorConversionStrategy::DEVICE_INDEPENDENT_COLOR) + ->optimize($file, $optimized); + + +# check result +if ($result->status) { + echo "PDF file optimized successfully!"; +} +else { + echo "Error: " . $result->message; +} +``` diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md new file mode 100644 index 0000000..27e8d55 --- /dev/null +++ b/docs/getting-started/installation.md @@ -0,0 +1,66 @@ +# Installation + +### Requirements: + +* PHP 8.2 or higher +* [Ghostscript](https://ghostscript.com) + + + +### 1. Install Ghostscript + +{% tabs %} +{% tab title="Ubuntu" %} +```shell +sudo apt update -y +sudo apt-get install ghostscript +``` +{% endtab %} + +{% tab title="Alpine" %} +```sh +sudo apk add --upgrade ghostscript +``` +{% endtab %} + +{% tab title="MacOS" %} +```bash +brew install ghostscript +``` +{% endtab %} + +{% tab title="Windows" %} +1. Download and install [Ghostscript](https://www.ghostscript.com/download/gsdnld.html) +2. Add Ghostscript to your system path +3. Restart your computer + + + +Note: This package has not been tested on Windows machines. While it is designed to work seamlessly on Unix-based systems, users on Windows may experience compatibility issues. + +We recommend testing the package in a Windows environment and welcome any feedback or contributions to enhance Windows compatibility. If you encounter issues or have suggestions for improving Windows support, please feel free to open an issue on our GitHub repository. Thank you for your understanding. +{% endtab %} +{% endtabs %} + +### 2. Install the package via composer + +```bash +composer require mostafaznv/pdf-optimizer +``` + +### 3. Publish config file (Laravel Only) + +```bash +php artisan vendor:publish --provider="Mostafaznv\PdfOptimizer\PdfOptimizerServiceProvider" +``` + +{% hint style="info" %} +If you're using Laravel, this command publishes the configuration file, allowing you to customize pdf-optimizer settings. +{% endhint %} + +### 4. Done + + + + + diff --git a/docs/getting-started/license.md b/docs/getting-started/license.md new file mode 100644 index 0000000..ed0918f --- /dev/null +++ b/docs/getting-started/license.md @@ -0,0 +1,4 @@ +# License + +Our software is open source and licensed under the [MIT license](https://choosealicense.com/licenses/mit/). You are free to use the software as you like. The code can be forked and modified, but the original copyright author should always be included! + diff --git a/docs/getting-started/support-us.md b/docs/getting-started/support-us.md new file mode 100644 index 0000000..74a8c40 --- /dev/null +++ b/docs/getting-started/support-us.md @@ -0,0 +1,14 @@ +# Support Us + +If you find this project useful, please consider supporting its ongoing development with a donation. Your donation will help cover the costs of development, maintenance, and infrastructure. + +I believe in open source software and its power to change the world for the better. However, I also recognize that developing and maintaining high-quality open source projects requires significant time and effort. By supporting me, you are helping to ensure that this project remains healthy and active, and that it can continue to benefit people around the world. + +Your contribution, no matter how small, is deeply appreciated. + +Thank you for your support! + +[![Donate](https://mostafaznv.github.io/donate/donate.svg)](https://mostafaznv.github.io/donate) + + + diff --git a/docs/laravel-deep-dive/filesystem.md b/docs/laravel-deep-dive/filesystem.md new file mode 100644 index 0000000..ee41153 --- /dev/null +++ b/docs/laravel-deep-dive/filesystem.md @@ -0,0 +1,203 @@ +# Filesystem + +`pdf-optimizer` seamlessly integrates with Laravel, offering versatile file optimization capabilities. **This feature extends beyond local paths, allowing you to optimize files from various sources, including remote disks and UploadedFile instances.** + +Explore the flexibility of optimizing files and storing them across different disks within the Laravel ecosystem. + + + +Here is some detailed examples: + +
+ +UploadedFile -> Disk + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; +use Illuminate\Http\UploadedFile; + + +$file = new UploadedFile( + public_path('files/input.pdf'), 'input.pdf' +); + +$result = PdfOptimizer::open($file) + ->toDisk('minio') + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize('output.pdf'); + +dd($result); +``` + +
+ +
+ +UploadedFile -> File Path + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; +use Illuminate\Http\UploadedFile; + +$outputFilePath = public_path('files/output.pdf'); +$file = new UploadedFile( + public_path('files/input.pdf'), 'input.pdf' +); + +$result = PdfOptimizer::open($file) + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize($outputFilePath); + +dd($result); +``` + +
+ +
+ +File Path -> File Path + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$inputFilePath = public_path('files/input.pdf'); +$outputFilePath = public_path('files/output.pdf'); + +$result = PdfOptimizer::open($inputFilePath) + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize($outputFilePath); + +dd($result); +``` + +
+ +
+ +File Path -> Disk + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$filePath = public_path('files/input.pdf'); + +$result = PdfOptimizer::open($filePath) + ->toDisk('minio') + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize('output.pdf'); + +dd($result); +``` + +
+ +
+ +Disk -> File Path + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$outputFilePath = public_path('files/output.pdf') + +$result = PdfOptimizer::fromDisk('minio') + ->open('input.pdf') + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize($outputFilePath); + +dd($result); +``` + +
+ +
+ +Remote Disk -> Remote Disk + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$result = PdfOptimizer::fromDisk('minio') + ->open('input.pdf') + ->toDisk('minio') + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize('output.pdf'); + +dd($result); +``` + +
+ +
+ +Remote Disk -> Local Disk + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$result = PdfOptimizer::fromDisk('minio') + ->open('input.pdf') + ->toDisk('local') + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize('output.pdf'); + + +dd($result); +``` + +
+ +
+ +Local Disk -> Remote Disk + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$result = PdfOptimizer::fromDisk('local') + ->open('input.pdf') + ->toDisk('minio') + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize('output.pdf'); + +dd($result); +``` + +
+ +
+ +Local Disk -> Local Disk + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; +use Mostafaznv\PdfOptimizer\Enums\PdfSettings; + +$result = PdfOptimizer::fromDisk('local') + ->open('input.pdf') + ->toDisk('local') + ->settings(PdfSettings::SCREEN) + ->colorImageResolution(50) + ->optimize('output.pdf'); + +dd($result); +``` + +
+ diff --git a/docs/laravel-deep-dive/queue.md b/docs/laravel-deep-dive/queue.md new file mode 100644 index 0000000..8b96bbc --- /dev/null +++ b/docs/laravel-deep-dive/queue.md @@ -0,0 +1,139 @@ +# Queue + +pdf-optimizer introduces a powerful feature that allows you to queue the optimization of your files seamlessly within the Laravel framework. Queueing files provides a convenient and efficient way to handle optimization tasks asynchronously, improving the responsiveness and performance of your application. + + + +### Key Benefits + +* **Asynchronous Processing:** Queueing enables the optimization of files in the background, preventing long processing times from affecting the user experience. +* **Scalability:** Easily handle large batches of files by distributing optimization tasks across multiple workers, ensuring optimal resource utilization. +* **Improved Performance:** By offloading optimization to the queue, your application remains responsive, providing a smoother user experience. + + + +There are two ways to enable the queue for optimizing processes. You can enable it globally through the `configuration` file or selectively using `onQueue` wherever you want to optimize a file. + + + +*** + +### Usage + +{% tabs %} +{% tab title="Using Method" %} +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; + +$result = PdfOptimizer::fromDisk('minio') + ->open('input.pdf') + ->toDisk('files') + ->onQueue() + ->optimize('output.pdf'); +``` + +The `onQueue` method accepts four optional arguments: + +* **enabled (boolean):** Responsible for enabling or disabling the queue. It is set to true by default. +* **name (string):** Customizes the queue name, which is set to the `default` value by default. +* **connection (string):** Customizes the connection of the queue process. It defaults to null. +* **timeout (int):** Sets the timeout for processes during the queue job. +{% endtab %} + +{% tab title="Using Config File" %} +{% code title="config/pdf-optimizer.php" %} +```php +return [ + // ... + + 'queue' => [ + 'enabled' => true, + 'name' => 'default', + 'connection' => null, + 'timeout' => 900 // seconds (15 minutes) + ] +]; +``` +{% endcode %} + +```php +use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer; + +$result = PdfOptimizer::fromDisk('minio') + ->open('input.pdf') + ->toDisk('files') + ->optimize('output.pdf'); +``` +{% endtab %} +{% endtabs %} + +{% hint style="info" %} +The `PdfOptimizer` class returns an `OptimizeResult` object that contains two properties: + +* **isQueued (boolean):** Indicates whether the optimization process has been queued. Defaults to false. +* **queueId (string):** Provides an `orderedUuid` for the queued optimization job. + + + +You can store the `queueId` in your database and monitor the optimization's result by listening to the `PdfOptimizerJobFinished` event. +{% endhint %} + + + +*** + +### Job Completion Event + +`pdf-optimizer` provides an event that fires when an optimization job finishes processing in the queue. This event can be used to perform additional actions once the job is complete, such as sending a notification to a user or updating a database record. The event can be listened to using Laravel's built-in event system, and it provides access to the `ID` of optimization job, status of the optimization process, and the message of executed command. \ +To utilize this feature, you need to create an event listener and register it. Once the job is completed, `pdf-optimizer` will notify your listener and provide the necessary information. + + + +1. **Craete a Listener** + +```bash +php artisan make:listener PdfOptimizerJobNotification +``` + +2. **Register Listener** + +{% code title="App\Providers\EventServiceProvider" %} +```php +use Mostafaznv\PdfOptimizer\Events\PdfOptimizerJobFinished; +use App\Listeners\PdfOptimizerJobNotification; + + +protected $listen = [ + PdfOptimizerJobFinished::class => [ + PdfOptimizerJobNotification::class, + ], +]; +``` +{% endcode %} + +3. **Listen to Notification** + +```php +id"); + info("status: $event->status"); + info("message: $event->message"); + } +} +``` + + + + + From 545733fd15b9001ee47e225efa084aae76d50cf7 Mon Sep 17 00:00:00 2001 From: Mostafa Zeinivand Date: Fri, 12 Jan 2024 17:10:31 +0000 Subject: [PATCH 2/6] GITBOOK-3: No subject From 61ca531735e68a6a21ac90376723676568af1e5b Mon Sep 17 00:00:00 2001 From: mostafaznv Date: Sun, 14 Jan 2024 01:02:41 +0330 Subject: [PATCH 3/6] wip --- tests/Unit/Laravel/Concerns/DiskTest.php | 2 +- tests/Unit/OptimizePdfActionTest.php | 5 ++--- tests/Unit/Properties/IntegerPropertiesTest.php | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/Unit/Laravel/Concerns/DiskTest.php b/tests/Unit/Laravel/Concerns/DiskTest.php index 6a9da8c..11d0313 100644 --- a/tests/Unit/Laravel/Concerns/DiskTest.php +++ b/tests/Unit/Laravel/Concerns/DiskTest.php @@ -112,7 +112,7 @@ expect(is_dir($tempDirectory))->toBeFalse(); }); -it('will assume driver not-local if disk is not set', function () { +it('will assume driver a not-local driver if disk is not set', function () { $disk = Disk::make(); expect($disk->isLocalDisk())->toBeFalse(); diff --git a/tests/Unit/OptimizePdfActionTest.php b/tests/Unit/OptimizePdfActionTest.php index abbadc5..9a90ce0 100644 --- a/tests/Unit/OptimizePdfActionTest.php +++ b/tests/Unit/OptimizePdfActionTest.php @@ -62,10 +62,9 @@ ->not()->toBe($file->getPath()) ->and($this->logger->getContext()) ->toHaveKey('input', $file->getPath()); - }); -it('will overwrite output when disk object is provided a local disk directly', function () { +it('will overwrite output when a disk(local) object is provided through init method', function () { OptimizePdfAction::init() ->logger($this->logger) ->execute( @@ -96,7 +95,7 @@ ->toHaveKey('output', $expectedOutput); }); -it('will overwrite output when disk object is provided a remote disk directly', function () { +it('will overwrite output when a disk(remote) object is provided through init method', function () { OptimizePdfAction::init() ->logger($this->logger) ->execute( diff --git a/tests/Unit/Properties/IntegerPropertiesTest.php b/tests/Unit/Properties/IntegerPropertiesTest.php index 0bf7278..346f464 100644 --- a/tests/Unit/Properties/IntegerPropertiesTest.php +++ b/tests/Unit/Properties/IntegerPropertiesTest.php @@ -26,7 +26,7 @@ it('will include the given option in the final script', function (string $option, string $method) { - $number = random_int(1, 10); + $number = fake()->numberBetween(1, 10); $command = $this->optimizer->$method($number)->command(); expect($command)->toContain("$option=$number"); From f28c1164792b4ab015a5f3c2c0ebe2c3e3d8611c Mon Sep 17 00:00:00 2001 From: mostafaznv Date: Sun, 14 Jan 2024 01:18:12 +0330 Subject: [PATCH 4/6] test: fix misconfiguration causing files to be stored in the root folder --- tests/Unit/OptimizePdfActionTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Unit/OptimizePdfActionTest.php b/tests/Unit/OptimizePdfActionTest.php index 9a90ce0..5d04d4e 100644 --- a/tests/Unit/OptimizePdfActionTest.php +++ b/tests/Unit/OptimizePdfActionTest.php @@ -226,10 +226,8 @@ }); it('will log output for successful actions', function () { - Storage::disk('s3')->put($this->input, file_get_contents(pdf())); - $result = $this->action->execute( - $this->fullCommand, pdf(), $this->output + $this->fullCommand, pdf(), output() ); $logs = $this->logger->getLogs(); From c18fc0a809182c0569f685b4b1152cbcc9493d74 Mon Sep 17 00:00:00 2001 From: mostafaznv Date: Wed, 17 Jan 2024 00:35:08 +0330 Subject: [PATCH 5/6] refactor: make all DTOs readonly --- src/DTOs/OptimizeResult.php | 2 +- src/DTOs/PdfOptimizerJobData.php | 20 ++++++++++---------- src/DTOs/QueueData.php | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/DTOs/OptimizeResult.php b/src/DTOs/OptimizeResult.php index 3efa9a0..c8f47d3 100644 --- a/src/DTOs/OptimizeResult.php +++ b/src/DTOs/OptimizeResult.php @@ -3,7 +3,7 @@ namespace Mostafaznv\PdfOptimizer\DTOs; -class OptimizeResult +readonly class OptimizeResult { public function __construct( public bool $status, diff --git a/src/DTOs/PdfOptimizerJobData.php b/src/DTOs/PdfOptimizerJobData.php index 0d7c8aa..706ae21 100644 --- a/src/DTOs/PdfOptimizerJobData.php +++ b/src/DTOs/PdfOptimizerJobData.php @@ -2,23 +2,23 @@ namespace Mostafaznv\PdfOptimizer\DTOs; - use Illuminate\Support\Str; use Mostafaznv\PdfOptimizer\Laravel\Concerns\Disk; use Mostafaznv\PdfOptimizer\Laravel\Concerns\File; use Psr\Log\LoggerInterface; -class PdfOptimizerJobData + +readonly class PdfOptimizerJobData { public function __construct( - public readonly string $id, - public readonly array $commands, - public readonly string $input, - public readonly string $output, - public readonly ?File $file = null, - public readonly ?Disk $disk = null, - public readonly ?LoggerInterface $logger = null, - public readonly int $timeout = 900 + public string $id, + public array $commands, + public string $input, + public string $output, + public ?File $file = null, + public ?Disk $disk = null, + public ?LoggerInterface $logger = null, + public int $timeout = 900 ) {} public static function make(array $commands, string $input, string $output, File $file, ?Disk $disk = null, ?LoggerInterface $logger = null, int $timeout = 900): self diff --git a/src/DTOs/QueueData.php b/src/DTOs/QueueData.php index 9b1a86e..bfad1cb 100644 --- a/src/DTOs/QueueData.php +++ b/src/DTOs/QueueData.php @@ -3,7 +3,7 @@ namespace Mostafaznv\PdfOptimizer\DTOs; -class QueueData +readonly class QueueData { public function __construct( public bool $enabled = false, From 51becd7499b6a83cac4387ab22941f96db1fadeb Mon Sep 17 00:00:00 2001 From: mostafaznv Date: Wed, 17 Jan 2024 00:35:33 +0330 Subject: [PATCH 6/6] refactor: remove unused $disk method in File class --- src/Laravel/Concerns/File.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Laravel/Concerns/File.php b/src/Laravel/Concerns/File.php index 895e635..3f0d291 100644 --- a/src/Laravel/Concerns/File.php +++ b/src/Laravel/Concerns/File.php @@ -6,14 +6,12 @@ class File { private string $path; - private ?string $disk; private Disk $diskInstance; public function __construct(string $path, ?string $disk = null) { $this->path = $path; - $this->disk = $disk; $this->diskInstance = Disk::make($disk); }