Com\Tecnick\Pdf\Parser\Parser
PHP class for parsing PDF documents.
Tags
Table of Contents
- $mrkoff : array<string|int, mixed>
- Store the processed offsets
- $objects : array<string|int, mixed>
- Array of PDF objects.
- $pdfdata : string
- Raw content of the PDF document.
- $xref : array<string|int, mixed>
- XREF data.
- $cfg : array<string|int, mixed>
- Array of configuration parameters.
- __construct() : mixed
- Initialize the PDF parser
- parse() : mixed
- Parse a PDF document into an array of objects
- decodeStream() : array<string|int, mixed>
- Decode the specified stream.
- decodeXref() : array<string|int, mixed>
- Decode the Cross-Reference section
- decodeXrefStream() : array<string|int, mixed>
- Decode the Cross-Reference Stream section
- getDeclaredStreamLength() : array<string|int, mixed>
- Get Filters
- getDecodedStream() : array<string|int, mixed>
- Decode the specified stream.
- getFilters() : array<string|int, mixed>
- Get Filters
- getIndirectObject() : array<string|int, mixed>
- Get content of indirect object.
- getObjectVal() : array<string|int, mixed>
- Get the content of object, resolving indect object reference if necessary.
- getRawIndirectObject() : array<string|int, mixed>
- Get content of indirect object.
- getRawObject() : array<string|int, mixed>
- Get object type, raw value and offset to next object
- getTrailerData() : array<string|int, mixed>
- Decode the Cross-Reference section
- getXrefData() : array<string|int, mixed>
- Get Cross-Reference (xref) table and trailer data from PDF document data.
- minDistance() : mixed
- Return minimum distance for PNG unpredictor
- pngUnpredictor() : mixed
- PNG Unpredictor
- processAngular() : mixed
- Process \x3C LESS-THAN SIGN and \x3E GREATER-THAN SIGN
- processBracket() : mixed
- Process array content \x5B LEFT SQUARE BRACKET and \x5D RIGHT SQUARE BRACKET
- processDdata() : mixed
- Process ddata
- processDefault() : mixed
- Process default
- processDefaultName() : bool
- Process default
- processObjIndexes() : mixed
- Process object indexes
- processParenthesis() : mixed
- Process literal string object \x28 LEFT PARENTHESIS and \x29 RIGHT PARENTHESIS
- processSolidus() : mixed
- Process name object \x2F SOLIDUS
- processXrefDecodeParms() : mixed
- Process XREF type DecodeParms
- processXrefObjref() : mixed
- Process XREF type Objref
- processXrefPrev() : mixed
- Process XREF type Prev
- processXrefType() : mixed
- Process XREF types
- processXrefTypeFt() : mixed
- Process XREF type
Properties
$mrkoff
Store the processed offsets
protected array<string|int,
mixed> $mrkoff = array()
$objects
Array of PDF objects.
protected array<string|int,
mixed> $objects = array()
$pdfdata
Raw content of the PDF document.
protected string $pdfdata = ''
$xref
XREF data.
protected array<string|int,
mixed> $xref = array()
$cfg
Array of configuration parameters.
private array<string|int,
mixed> $cfg = array('ignore_filter_errors'
=> false)
Methods
__construct()
Initialize the PDF parser
public __construct([array<string|int,
mixed> $cfg
= array()
]) : mixed
Parameters
- $cfg : array<string|int, mixed> = array()
-
Array of configuration parameters: 'ignore_filter_decoding_errors' : if true ignore filter decoding errors; 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors.
Return values
mixed —parse()
Parse a PDF document into an array of objects
public parse(string $data)
: mixed
Parameters
- $data : string
-
PDF data to parse.
Return values
mixed —decodeStream()
Decode the specified stream.
protected decodeStream(array<string|int,
mixed> $sdic,
string $stream)
: array<string|int,
mixed>
Parameters
- $sdic : array<string|int, mixed>
-
Stream's dictionary array.
- $stream : string
-
Stream to decode.
Return values
array<string|int, mixed> —Decoded stream data and remaining filters.
decodeXref()
Decode the Cross-Reference section
protected decodeXref(int $startxref[,
array<string|int,
mixed> $xref
= array()
]) : array<string|int,
mixed>
Parameters
- $startxref : int
-
Offset at which the xref section starts (position of the 'xref' keyword).
- $xref : array<string|int, mixed> = array()
-
Previous xref array (if any).
Return values
array<string|int, mixed> —Xref and trailer data.
decodeXrefStream()
Decode the Cross-Reference Stream section
protected decodeXrefStream(int $startxref[,
array<string|int,
mixed> $xref
= array()
]) : array<string|int,
mixed>
Parameters
- $startxref : int
-
Offset at which the xref section starts.
- $xref : array<string|int, mixed> = array()
-
Previous xref array (if any).
Return values
array<string|int, mixed> —Xref and trailer data.
getDeclaredStreamLength()
Get Filters
protected getDeclaredStreamLength(string &$stream,
int &$slength,
array<string|int,
mixed> $sdic,
int $key)
: array<string|int,
mixed>
Parameters
- $stream : string
-
Stream
- $slength : int
-
Stream length
- $sdic : array<string|int, mixed>
-
Stream's dictionary array.
- $key : int
-
Index
Return values
array<string|int, mixed> —Array of filters
getDecodedStream()
Decode the specified stream.
protected getDecodedStream(array<string|int,
mixed> $filters,
string $stream)
: array<string|int,
mixed>
Parameters
- $filters : array<string|int, mixed>
-
Array of decoding filters to apply
- $stream : string
-
Stream to decode.
Return values
array<string|int, mixed> —Decoded stream data and remaining filters.
getFilters()
Get Filters
protected getFilters(array<string|int,
mixed> $filters,
array<string|int,
mixed> $sdic,
int $key)
: array<string|int,
mixed>
Parameters
- $filters : array<string|int, mixed>
-
Array of Filters
- $sdic : array<string|int, mixed>
-
Stream's dictionary array.
- $key : int
-
Index
Return values
array<string|int, mixed> —Array of filters
getIndirectObject()
Get content of indirect object.
protected getIndirectObject(string $obj_ref,
int $offset[,
bool $decoding
= true
]) : array<string|int,
mixed>
Parameters
- $obj_ref : string
-
Object number and generation number separated by underscore character.
- $offset : int
-
Object offset.
- $decoding : bool = true
-
If true decode streams.
Return values
array<string|int, mixed> —Object data.
getObjectVal()
Get the content of object, resolving indect object reference if necessary.
protected getObjectVal(string $obj)
: array<string|int,
mixed>
Parameters
- $obj : string
-
Object value.
Return values
array<string|int, mixed> —Object data.
getRawIndirectObject()
Get content of indirect object.
protected getRawIndirectObject(int $offset,
bool $decoding)
: array<string|int,
mixed>
Parameters
- $offset : int
-
Object offset.
- $decoding : bool
-
If true decode streams.
Return values
array<string|int, mixed> —Object data.
getRawObject()
Get object type, raw value and offset to next object
protected getRawObject(int $offset)
: array<string|int,
mixed>
Parameters
- $offset : int
-
Object offset.
Return values
array<string|int, mixed> —Array containing object type, raw value and offset to next object
getTrailerData()
Decode the Cross-Reference section
protected getTrailerData(array<string|int,
mixed> $xref,
array<string|int,
mixed> $matches)
: array<string|int,
mixed>
Parameters
- $xref : array<string|int, mixed>
-
Previous xref array (if any).
- $matches : array<string|int, mixed>
-
Matches containing traile sections
Return values
array<string|int, mixed> —Xref and trailer data.
getXrefData()
Get Cross-Reference (xref) table and trailer data from PDF document data.
protected getXrefData(int $offset[,
array<string|int,
mixed> $xref
= array()
]) : array<string|int,
mixed>
Parameters
- $offset : int
-
Xref offset (if know).
- $xref : array<string|int, mixed> = array()
-
Previous xref array (if any).
Return values
array<string|int, mixed> —Xref and trailer data.
minDistance()
Return minimum distance for PNG unpredictor
protected minDistance(array<string|int,
mixed> &$ddata,
mixed $key,
array<string|int,
mixed> $row,
int $idx,
int $jdx,
int $row_left,
int $row_up,
int $row_upleft)
: mixed
Parameters
- $ddata : array<string|int, mixed>
- $key : mixed
- $row : array<string|int, mixed>
- $idx : int
- $jdx : int
- $row_left : int
- $row_up : int
- $row_upleft : int
Return values
mixed —pngUnpredictor()
PNG Unpredictor
protected pngUnpredictor(array<string|int,
mixed> $sdata,
array<string|int,
mixed> &$ddata,
int $columns,
int $prev_row)
: mixed
Parameters
- $sdata : array<string|int, mixed>
- $ddata : array<string|int, mixed>
- $columns : int
- $prev_row : int
Return values
mixed —processAngular()
Process \x3C LESS-THAN SIGN and \x3E GREATER-THAN SIGN
protected processAngular(string $char,
int &$offset,
string &$objtype,
string &$objval)
: mixed
Parameters
- $char : string
-
Symbol to process
- $offset : int
-
Offset
- $objtype : string
-
Object type
- $objval : string
-
Object content
Return values
mixed —processBracket()
Process array content \x5B LEFT SQUARE BRACKET and \x5D RIGHT SQUARE BRACKET
protected processBracket(string $char,
int &$offset,
string &$objtype,
string &$objval)
: mixed
Parameters
- $char : string
-
Symbol to process
- $offset : int
-
Offset
- $objtype : string
-
Object type
- $objval : string
-
Object content
Return values
mixed —processDdata()
Process ddata
protected processDdata(array<string|int,
mixed> &$sdata,
array<string|int,
mixed> $ddata,
array<string|int,
mixed> $wbt)
: mixed
Parameters
- $sdata : array<string|int, mixed>
- $ddata : array<string|int, mixed>
- $wbt : array<string|int, mixed>
Return values
mixed —processDefault()
Process default
protected processDefault(int &$offset,
string &$objtype,
string &$objval)
: mixed
Parameters
- $offset : int
-
Offset
- $objtype : string
-
Object type
- $objval : string
-
Object content
Return values
mixed —processDefaultName()
Process default
protected processDefaultName(int &$offset,
string &$objtype,
string &$objval)
: bool
Parameters
- $offset : int
-
Offset
- $objtype : string
-
Object type
- $objval : string
-
Object content
Return values
bool —True in case of match, flase otherwise
processObjIndexes()
Process object indexes
protected processObjIndexes(array<string|int,
mixed> &$xref,
int &$obj_num,
array<string|int,
mixed> $sdata)
: mixed
Parameters
- $xref : array<string|int, mixed>
- $obj_num : int
- $sdata : array<string|int, mixed>
Return values
mixed —processParenthesis()
Process literal string object \x28 LEFT PARENTHESIS and \x29 RIGHT PARENTHESIS
protected processParenthesis(string $char,
int &$offset,
string &$objtype,
string &$objval)
: mixed
Parameters
- $char : string
-
Symbol to process
- $offset : int
-
Offset
- $objtype : string
-
Object type
- $objval : string
-
Object content
Return values
mixed —processSolidus()
Process name object \x2F SOLIDUS
protected processSolidus(string $char,
int &$offset,
string &$objtype,
string &$objval)
: mixed
Parameters
- $char : string
-
Symbol to process
- $offset : int
-
Offset
- $objtype : string
-
Object type
- $objval : string
-
Object content
Return values
mixed —processXrefDecodeParms()
Process XREF type DecodeParms
protected processXrefDecodeParms(array<string|int,
mixed> $sarr,
int $key,
int &$columns)
: mixed
Parameters
- $sarr : array<string|int, mixed>
- $key : int
- $columns : int
Return values
mixed —processXrefObjref()
Process XREF type Objref
protected processXrefObjref(string $type,
array<string|int,
mixed> $sarr,
mixed $key,
array<string|int,
mixed> &$xref)
: mixed
Parameters
- $type : string
- $sarr : array<string|int, mixed>
- $key : mixed
- $xref : array<string|int, mixed>
Return values
mixed —processXrefPrev()
Process XREF type Prev
protected processXrefPrev(array<string|int,
mixed> $sarr,
int $key,
int &$prevxref)
: mixed
Parameters
- $sarr : array<string|int, mixed>
- $key : int
- $prevxref : int
Return values
mixed —processXrefType()
Process XREF types
protected processXrefType(array<string|int,
mixed> $sarr,
array<string|int,
mixed> &$xref,
array<string|int,
mixed> &$wbt,
int &$index_first,
int &$prevxref,
int &$columns,
bool &$valid_crs,
bool $filltrailer)
: mixed
Parameters
- $sarr : array<string|int, mixed>
- $xref : array<string|int, mixed>
- $wbt : array<string|int, mixed>
- $index_first : int
- $prevxref : int
- $columns : int
- $valid_crs : bool
- $filltrailer : bool
Return values
mixed —processXrefTypeFt()
Process XREF type
protected processXrefTypeFt(string $type,
array<string|int,
mixed> $sarr,
mixed $key,
array<string|int,
mixed> &$xref,
bool $filltrailer)
: mixed
Parameters
- $type : string
- $sarr : array<string|int, mixed>
- $key : mixed
- $xref : array<string|int, mixed>
- $filltrailer : bool