PathInput
extends LocalInputSource
in package
Local path input.
Table of Contents
Properties
- $fileMimetype : string
- $fileName : string
- $fileObject : CURLFile
- $filePath : string|null
- $pageCount : int|null
Methods
- __construct() : mixed
- Base constructor, mostly used for Mime type checking.
- applyPageOptions() : void
- Applies PDF-specific operations on the current file based on the specified PageOptions.
- checkNeedsFix() : void
- Checks if the file needs fixing.
- compress() : void
- Compress a file and update the file object (does not alter the original file).
- fixPdf() : void
- Attempts to fix a PDF file.
- getFileSize() : int
- Returns the file size of the current file.
- hasSourceText() : bool
- Checks the source file for source text.
- isPdf() : bool
- Checks whether the file type is a PDF.
- isPdfEmpty() : bool
- Checks whether the contents of a PDF are empty.
- readContents() : array{0: string, 1: string}
- Reads the contents of the file.
- getPageCount() : int
- Counts the amount of pages in a PDF.
Properties
$fileMimetype
public
string
$fileMimetype
File Mime type, as a string.
$fileName
public
string
$fileName
Name of the file, mandatory for proper Mime type handling server-side.
$fileObject
public
CURLFile
$fileObject
File object, as a CURLFile for simplicity.
$filePath
public
string|null
$filePath
= null
Path of the file for files retrieved from a path.
$pageCount
public
int|null
$pageCount
= null
Page count.
Methods
__construct()
Base constructor, mostly used for Mime type checking.
public
__construct(string $filePath) : mixed
Parameters
- $filePath : string
-
Path to open.
applyPageOptions()
Applies PDF-specific operations on the current file based on the specified PageOptions.
public
applyPageOptions(PageOptions|null $pageOptions) : void
Parameters
- $pageOptions : PageOptions|null
-
The options specifying which pages to modify or retain in the PDF file.
Tags
checkNeedsFix()
Checks if the file needs fixing.
public
checkNeedsFix() : void
compress()
Compress a file and update the file object (does not alter the original file).
public
compress([int $quality = 85 ][, int|null $maxWidth = null ][, int|null $maxHeight = null ][, bool $forceSourceTextCompression = false ][, bool $disableSourceText = true ][, bool $optimize = true ][, float|null $dpi = 100 ]) : void
Parameters
- $quality : int = 85
-
Quality of the output file.
- $maxWidth : int|null = null
-
Maximum width (Ignored for PDFs).
- $maxHeight : int|null = null
-
Maximum height (Ignored for PDFs).
- $forceSourceTextCompression : bool = false
- $disableSourceText : bool = true
- $optimize : bool = true
-
Whether to optimize the output file. Disabling this may result in a larger file, which will revert to the original.
- $dpi : float|null = 100
-
DPI of the output file.
Tags
fixPdf()
Attempts to fix a PDF file.
public
fixPdf([int $maximumOffset = 500 ]) : void
Parameters
- $maximumOffset : int = 500
Tags
getFileSize()
Returns the file size of the current file.
public
getFileSize() : int
Tags
Return values
int —The file size in bytes.
hasSourceText()
Checks the source file for source text.
public
hasSourceText() : bool
Tags
Return values
bool —Returns false if none is found, or if the file isn't a PDF.
isPdf()
Checks whether the file type is a PDF.
public
isPdf() : bool
Return values
boolisPdfEmpty()
Checks whether the contents of a PDF are empty.
public
isPdfEmpty() : bool
Tags
Return values
boolreadContents()
Reads the contents of the file.
public
readContents() : array{0: string, 1: string}
Return values
array{0: string, 1: string} —File name and contents as a tuple.
getPageCount()
Counts the amount of pages in a PDF.
protected
getPageCount() : int
Tags
Return values
int —Page count.