PdfCompressor
in package
PDF compression class.
Table of Contents
Methods
- compress() : CURLFile
- Compresses each page of a provided PDF stream. Skips if force_source_text isn't set and source text is detected.
- injectTextForPage() : void
- processPdfPage() : array{0: string, 1: string}
- Processes a single PDF page, rasterizing it to a JPEG image.
Methods
compress()
Compresses each page of a provided PDF stream. Skips if force_source_text isn't set and source text is detected.
public
static compress(resource|string|SplFileObject|CURLFile $input[, int $quality = 85 ][, bool $forceSourceTextCompression = false ][, bool $disableSourceText = true ]) : CURLFile
Parameters
- $input : resource|string|SplFileObject|CURLFile
-
Path to the PDF file.
- $quality : int = 85
-
Compression quality (70-100 for most JPG images in the test dataset).
- $forceSourceTextCompression : bool = false
-
If true, attempts to re-write detected text.
- $disableSourceText : bool = true
-
If true, doesn't re-apply source text to the original PDF.
Tags
Return values
CURLFileinjectTextForPage()
protected
static injectTextForPage(Page $inputPage, CustomFpdi $outputPdf) : void
Parameters
- $inputPage : Page
-
Input page.
- $outputPdf : CustomFpdi
-
Output PDF handle.
Tags
processPdfPage()
Processes a single PDF page, rasterizing it to a JPEG image.
protected
static processPdfPage(string $sourcePdfPath, int $pageIndex, int $imageQuality) : array{0: string, 1: string}
Parameters
- $sourcePdfPath : string
-
Path to the source PDF file.
- $pageIndex : int
-
The index of the page to process.
- $imageQuality : int
-
The quality setting for JPEG compression.
Tags
Return values
array{0: string, 1: string} —Path to the temporary JPEG file and orientation of the page.