setasign\SetaPDF2\Core\Type

PdfObjectStream Class representing an object stream object.

File: /SetaPDF v2/Core/Type/PdfObjectStream.php
Old class name (alias): \SetaPDF_Core_Type_ObjectStream

Class hierarchy

Implements

Summary

Properties

$_bypassSecHandler

protected bool PdfStream::$_bypassSecHandler = false

Flag indicating that the object should bypass the security handler

$_encrypted

protected bool PdfStream::$_encrypted = false

Flag saying that the stream is encrypted or not

$_filtered

protected bool PdfStream::$_filtered = false

Flag saying that the current stream data is filtered or not

$_isNew

protected bool PdfObjectStream::$_isNew = false

Flag telling whether this object stream is a newly created one or read from an existing stream.

$_objectOffsets

protected array PdfObjectStream::$_objectOffsets = array()

An array of object offsets in the stream keyed by object ids.

$_observed

protected bool AbstractType::$_observed = false

Defines if this object is under observation

$_observers

protected array AbstractType::$_observers = array()

The Objects to notify on any change

This will be the PDF document or another value holding this one. Initially this will be an array.

$_owner

The document instance to which this object stream belongs to.

$_owningObject

The original owning object

Needed if the stream is encrypted

$_parser

The stream parser instance.

$_stream

protected string PdfStream::$_stream = ''

The stream content

$_unfilteredStream

The unfiltered stream content

$_valid

protected bool PdfObjectStream::$_valid = true

Defines if a inner object had triggered a change to invalid the state of this object stream.

$_value

The dictionary of the stream object

$metadata

public array AbstractType::$metadata = array()

An array for individual metadata.


Static Methods

_ensureType()

protected static AbstractType::_ensureType (
string $type,
mixed $value,
string $errorMessage,
$ensure = true
): mixed

Ensure that a value is an instance of a specific PDF type.

Parameters
$type : string
 
$value : mixed
 
$errorMessage : string
 
$ensure
 
Exceptions

Throws Exception

create()

public static PdfObjectStream::create (): self
Parameters
$document : \SetaPDF_Core_Document
 

ensureType()

public static PdfObjectStream::ensureType (
mixed $stream
): self

Ensures that the passed value is a PdfObjectStream instance.

Parameters
$stream : mixed
 
Exceptions

Throws Exception

ensureWithType()

public static AbstractType::ensureWithType (
string $type,
mixed $value
): \SetaPDF_Core_Type_AbstractType

Ensures that the passed value is an instance of the passed type.

Parameters
$type : string
 
$value : mixed
 
Exceptions

Throws Exception

is()

public static AbstractType::is (
string $type,
mixed $value,
bool $ensure = true
): bool

Checks if the type of a value is the expected one.

Indirect references will be evaluated if $ensure is set to true.

Parameters
$type : string
 
$value : mixed
 
$ensure : bool
 

writePdfString()

public static AbstractType::writePdfString (
\SetaPDF_Core_WriteInterface $writer,
mixed $value
): void

Parses a php value to a pdf string and writes it into a writer.

PHP data type -> PDF data type

Null -> PdfNull

Boolean -> PdfBoolean

Integer/Double -> PdfNumeric

String -> PdfString or PdfName(if the string starts with "/")

Indexed array -> PdfArray

Associative array -> PdfDictionary

Parameters
$writer : \SetaPDF_Core_WriteInterface
 
$value : mixed
 
Exceptions

Throws \InvalidArgumentException


Methods

__construct()

public PdfStream::__construct (
?\SetaPDF_Core_Type_Dictionary $value = null,
string $stream = '',
?\SetaPDF_Core_Type_IndirectObject $owningObject = null
)

The constructor.

Parameters
$value : ?\SetaPDF_Core_Type_Dictionary
 
$stream : string
 
$owningObject : ?\SetaPDF_Core_Type_IndirectObject
 

__sleep()

public AbstractType::__sleep (
void
): array

Implementation of __sleep.

We remove the observers from all elements because they will get read if they are waked up in an observed object.

_applyFilter()

protected PdfStream::_applyFilter (
string $stream,
bool $encode = false,
?\SetaPDF_Core_Document $pdfDocument = null
): mixed

Applies filter to the stream.

Parameters
$stream : string
 
$encode : bool
 
$pdfDocument : ?\SetaPDF_Core_Document

The document, on which the stream will get used. This value is only needed for a crypt filter (to be implemented!)

Exceptions

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

_decrypt()

protected PdfStream::_decrypt (
void
): string

Decrypts the stream (if needed).

_getBeforeSaveCallbackName()

protected PdfObjectStream::_getBeforeSaveCallbackName (
void
): string

_getObjectOffset()

protected PdfObjectStream::_getObjectOffset (
int $objectId
): int

Get the offset value for a specific object id.

Parameters
$objectId : int
 
Exceptions

Throws \setasign\SetaPDF2\Core\Document\ObjectNotFoundException

Throws Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

_getUnfilteredStream()

protected PdfObjectStream::_getUnfilteredStream (
void
): string

A proxy method to hold a copy of the unfiltered stream.

Exceptions

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

_preProcess()

protected PdfStream::_preProcess (
\SetaPDF_Core_Document $pdfDocument
): mixed|string

Pre-Process the stream for the output in a specific PDF document.

Parameters
$pdfDocument : \SetaPDF_Core_Document
 

addObject()

Add an indirect object to this object stream.

Parameters
$object : \SetaPDF_Core_Type_IndirectObject
 

appendStream()

public PdfStream::appendStream (
string $bytes
): void

Append a stream to the existing stream.

Parameters
$bytes : string
 

attach()

public PdfStream::attach (
\SplObserver $observer
): void

Add an observer to the object.

Implementation of the Observer Pattern.

Parameters
$observer : \SplObserver
 

cleanUp()

public PdfObjectStream::cleanUp (
void
): void

Release memory/cycled references.

clear()

public PdfStream::clear (
void
): void

Clears the stream.

deepClone()

Clone the object recursively in the context of a document.

Parameters
$document : \SetaPDF_Core_Document
 

detach()

public AbstractType::detach (
\SplObserver $observer
): void

Detach an observer from the object.

Implementation of the Observer Pattern.

Parameters
$observer : \SplObserver
 

detachAll()

public AbstractType::detachAll (
void
): void

Detach all observers from this object.

Be careful with this method!!!

ensure()

public AbstractType::ensure (
?bool $forceObservation = null,
array &$ensuredObjectsList = array ( )
): \SetaPDF_Core_Type_AbstractType

Returns the main value.

This method is used for automatically resolving of indirect references.

Parameters
$forceObservation : ?bool
 
$ensuredObjectsList : array

A list of all ensured indirect objects to prevent recursion

getOffsets()

public PdfObjectStream::getOffsets (
void
): array

Get the offsets of all objects in this object stream.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getOwner()

Get the owner instance.

getOwnerPdfDocument()

Get the document instance.

getStream()

public PdfStream::getStream (
bool $ignoreFaultyStreams = false,
bool $filtered = false
): string

Get the plain stream content.

Parameters
$ignoreFaultyStreams : bool
 
$filtered : bool
 
Exceptions

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getValue()

Get the dictionary of this stream.

hasCryptFilter()

public PdfStream::hasCryptFilter (
void
): bool

Checks if a Crypt filter is defined for this stream.

Exceptions

Throws Exception

isNew()

public PdfObjectStream::isNew (
void
): bool

Checks whether this object stream is a newly created one or created from an existing one.

isObserved()

public AbstractType::isObserved (
void
): bool

Checks if this object is observed.

isValid()

public PdfObjectStream::isValid (
void
): bool

Checks whether an object of this objects stream was changed or not.

notify()

public AbstractType::notify (
void
): void

Notifies all attached observers.

Implementation of the Observer Pattern.

Has to be called by any method that changes a value.

processObjects()

public PdfObjectStream::processObjects (
void
): array

Create the final stream based on the added objects.

Exceptions

Throws Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

setBypassSecHandler()

public PdfStream::setBypassSecHandler (
bool $bypassSecHandler = true
): void

Set the bypass security handler flag.

Parameters
$bypassSecHandler : bool
 

setOwner()

Set the owner instance.

Parameters
$owner : \SetaPDF_Core_Type_Owner
 

setStream()

public PdfStream::setStream (
string $stream
): void

Set the stream content.

Parameters
$stream : string
 

setValue()

Set the PDF dictionary for this stream object.

Parameters
$value : \SetaPDF_Core_Type_Dictionary

The value

Exceptions

Throws \InvalidArgumentException

See

toPdfString()

public PdfStream::toPdfString (
?\SetaPDF_Core_Document $pdfDocument = null
): string

Returns the type as a formatted PDF string.

Parameters
$pdfDocument : ?\SetaPDF_Core_Document
 

toPhp()

public PdfStream::toPhp (
void
): array

Converts the PDF data type to a PHP data type and returns it.

unfilterStream()

public PdfStream::unfilterStream (
void
): void

Unfilter the stream.

update()

public PdfObjectStream::update (
\SplSubject $subject
): void

Triggered if a value of this object is changed. Forward this to the document in that case.

A stream can only be observed by an indirect object.

So let's check the observers for this type and forward it to its owning document instance. It's hard to tell if the whole object stream should be rewritten or only the single modified object.

Parameters
$subject : \SplSubject
 

write()

public PdfStream::write (
string $bytes
): void

Alias for PdfStream::appendStream.

Parameters
$bytes : string
 

writeTo()

public PdfStream::writeTo (
\SetaPDF_Core_Document $pdfDocument
): void

Writes the type as a formatted PDF string to the document.

Parameters
$pdfDocument : \SetaPDF_Core_Document