Base64Input
extends LocalInputSource
in package
Base64-encoded text input.
Table of Contents
Properties
- $fileMimetype : string
- $fileName : string
- $fileObject : CURLFile
- $filePath : string|null
- $tempFile : string
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
- countDocPages() : int
- Counts the amount of pages in a PDF.
- fixPDF() : void
- Attempts to fix a PDF 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.
- mergePDFPages() : void
- Create a new PDF from pages and set it as the main file object.
- readContents() : array<string|int, mixed>
- Reads the contents of the file.
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.
$tempFile
private
string
$tempFile
Temporary file.
Methods
__construct()
Base constructor, mostly used for Mime type checking.
public
__construct(string $strBase64, string $fileName) : mixed
Parameters
- $strBase64 : string
-
Raw data as a base64-encoded string.
- $fileName : string
-
File name of the input.
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()
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
intfixPDF()
Attempts to fix a PDF file.
public
fixPDF() : void
Tags
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
readContents()
Reads the contents of the file.
public
readContents() : array<string|int, mixed>