PathInput
extends LocalInputSource
in package
Local path input.
Table of Contents
Properties
- $fileMimetype : string
- $fileName : string
- $fileObject : CURLFile
- $filePath : string|null
- $throwsOnClose : bool
Methods
- __construct() : mixed
- Base constructor, mostly used for Mime type checking.
- close() : void
- Closes the handle/stream, if the input type supports it.
- compress() : void
- countDocPages() : int
- Counts the amount of pages in a PDF.
- enableStrictMode() : void
- Enables strict mode.
- 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.
- mergePDFPages() : void
- Create a new PDF from pages and set it as the main file object.
- processPDF() : void
- Processes a PDF file.
- readContents() : array<string|int, mixed>
- Reads the contents of the file.
- checkMimeType() : void
- Checks the mimetype integrity of a file.
- fixPDF() : void
- Attempts to fix a PDF file.
- saveBytesAsFile() : void
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
Path of the file for files retrieved from a path.
$throwsOnClose
protected
bool
$throwsOnClose
Sets the input mode to debug. Only used in unit tests.
Methods
__construct()
Base constructor, mostly used for Mime type checking.
public
__construct(string $filePath[, bool $fixPDF = false ]) : mixed
Parameters
- $filePath : string
-
Path to open.
- $fixPDF : bool = false
-
Whether the PDF should be fixed or not.
close()
Closes the handle/stream, if the input type supports it.
public
close() : void
Tags
compress()
public
compress([int $quality = 85 ][, int|null $maxWidth = null ][, int|null $maxHeight = null ][, bool $forceSourceTextCompression = false ][, bool $disableSourceText = true ]) : 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
-
Whether to force the operation on PDFs with source text. This will attempt to re-render PDF text over the rasterized original. The script will attempt to re-write text, but might not support all fonts & encoding. If disabled, ignored the operation. WARNING: this operation is strongly discouraged.
- $disableSourceText : bool = true
-
If the PDF has source text, whether to re-apply it to the original or not. Needs force_source_text to work.
countDocPages()
Counts the amount of pages in a PDF.
public
countDocPages() : int
Tags
Return values
intenableStrictMode()
Enables strict mode.
public
enableStrictMode() : void
Currently only used to throw on misuse of close().
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([int $threshold = 1024 ]) : bool
Parameters
- $threshold : int = 1024
-
Semi-arbitrary threshold of minimum bytes on the page for it to be considered empty.
Tags
Return values
boolmergePDFPages()
Create a new PDF from pages and set it as the main file object.
public
mergePDFPages(array<string|int, mixed> $pageNumbers) : void
Parameters
- $pageNumbers : array<string|int, mixed>
-
Array of page numbers to add to the newly created PDF.
Tags
processPDF()
Processes a PDF file.
public
processPDF(string $behavior, int $onMinPages, array<string|int, mixed> $pageIndexes) : void
To be implemented.
Parameters
- $behavior : string
-
Behaviors available: KEEP_ONLY, REMOVE.
- $onMinPages : int
-
Minimum of pages to apply the operation.
- $pageIndexes : array<string|int, mixed>
-
Indexes of the pages to apply the operation to.
Tags
readContents()
Reads the contents of the file.
public
readContents() : array<string|int, mixed>
Return values
array<string|int, mixed>checkMimeType()
Checks the mimetype integrity of a file.
private
checkMimeType() : void
Tags
fixPDF()
Attempts to fix a PDF file.
private
fixPDF() : void
Tags
saveBytesAsFile()
private
saveBytesAsFile(string $fileBytes) : void
Parameters
- $fileBytes : string
-
Raw data as bytes.