Documentation

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

Throws if the operation fails at any step. //phpcs:disable

MindeeUnhandledException

Throws if one of the dependencies isn't installed.

Return values
CURLFile

injectTextForPage()

protected static injectTextForPage(Page $inputPage, CustomFpdi $outputPdf) : void
Parameters
$inputPage : Page

Input page.

$outputPdf : CustomFpdi

Output PDF handle.

Tags
throws
MindeePdfException

Throws if text can't be inserted into the page.

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

If there's an error processing the page.

Return values
array{0: string, 1: string}

Path to the temporary JPEG file and orientation of the page.

On this page

Search results