Documentation

LocalInputSource extends InputSource
in package

AbstractYes

Base class for all input sources coming from the local machine.

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.
checkMimeType()  : void
Checks the mimetype integrity of a file.
currentBytes()  : string
Reads the current file's bytes: the original file, or the result of the last fix, compression or page operation. Unlike readContents(), which some sources only allow once, this can be called any number of times.
saveBytesAsFile()  : void

Properties

$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.

Methods

__construct()

Base constructor, mostly used for Mime type checking.

public __construct() : mixed

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

If a PDF processing error occurs during the operation.

MindeeSourceException|Exception

If the file isn't a PDF, or can't be read.

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

Throws if the file can't be compressed.

fixPdf()

Attempts to fix a PDF file.

public fixPdf([int $maximumOffset = 500 ]) : void
Parameters
$maximumOffset : int = 500
Tags
throws
MindeeSourceException

Throws if the file can't be read or couldn't be fixed.

getFileSize()

Returns the file size of the current file.

public getFileSize() : int
Tags
throws
MindeeSourceException

Throws an exception if the file size cannot be determined.

Return values
int —

The file size in bytes.

hasSourceText()

Checks the source file for source text.

public hasSourceText() : bool
Tags
throws
MindeeSourceException

Throws if the file can't be read.

Exception

Throws if PDF can't be processed.

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
bool

readContents()

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.

currentBytes()

Reads the current file's bytes: the original file, or the result of the last fix, compression or page operation. Unlike readContents(), which some sources only allow once, this can be called any number of times.

private currentBytes() : string
Tags
throws
MindeeSourceException

Throws if the file can't be read.

Return values
string —

The file's contents.

saveBytesAsFile()

private saveBytesAsFile(string $fileBytes) : void
Parameters
$fileBytes : string

Raw data as bytes.

On this page

Search results