setasign\SetaPDF2\Core\Writer

HttpWriter A writer class for HTTP delivery

File: /SetaPDF v2/Core/Writer/HttpWriter.php
Old class name (alias): \SetaPDF_Core_Writer_Http

Class hierarchy

Implements

Summary

Properties

$_buffer

protected string TempStreamWriter::$_buffer = ''

$_bufferSize

protected int TempStreamWriter::$_bufferSize = 10000

$_filename

protected string HttpWriter::$_filename = 'document.pdf'

The document filename

$_handle

protected resource StreamWriter::$_handle

The file stream resource

$_inline

protected bool HttpWriter::$_inline = false

Flag saying that the file should be displayed inline or not

$_outputChunkSize

protected int HttpWriter::$_outputChunkSize = 4194304

Chunk size that is output at once.

$_status

protected string AbstractWriter::$_status = 0

Status property


Static Methods

encodeFilenameForHttpHeader()

public static HttpWriter::encodeFilenameForHttpHeader (
string $filename
): string

Encodes the file name for the http header.

Parameters
$filename : string
 

Methods

__construct()

public HttpWriter::__construct (
string $filename = 'document.pdf',
bool $inline = false
)

The constructor.

Parameters
$filename : string

The document filename in UTF-8 encoding

$inline : bool

Defines if the document should be displayed inline or if a download should be forced

__destruct()

public TempStreamWriter::__destruct (
void
): void

The deconstructor closes the file handle.

_flush()

protected TempStreamWriter::_flush (
void
): void

Flushes the buffer to the stream and resets the buffer.

_setHandle()

protected StreamWriter::_setHandle (
resource $handle
): void

Set the stream handle.

Parameters
$handle : resource
 

cleanUp()

public AbstractWriter::cleanUp (
void
): void

Method which should/will be called when the document objects cleanUp() method is called.

copy()

WARNING: This method is marked as deprecated!

Use copyStream() instead.

public StreamWriter::copy (
resource|\SetaPDF_Core_Writer_Stream $source
): void
Parameters
$source : resource|\SetaPDF_Core_Writer_Stream
 

copyStream()

public StreamWriter::copyStream (
resource|\SetaPDF_Core_Writer_Stream $source
): void

Copies an existing stream into the target stream.

Parameters
$source : resource|\SetaPDF_Core_Writer_Stream
 

finish()

public HttpWriter::finish (
void
): void

This method is called when the writing process is finished.

It sends the HTTP headers and send the buffer to the client.

Exceptions

Throws Exception

getHandle()

public TempStreamWriter::getHandle (
void
): resource

Gets the handle of the stream.

This method is overwritten to ensure that the handle is only accessed when the writer instance has the status "finished".

getPos()

public TempStreamWriter::getPos (
void
): int

Returns the current position.

getStatus()

public AbstractWriter::getStatus (
void
): string

Get the current status of the writer object.

setOutputChunkSize()

public HttpWriter::setOutputChunkSize (
int $outputChunkSize
): void

Set the chunk size of the data that is read from the internal stream and echoed.

The default value is 4 MB. You may increase this which may speed up the delivery of large files but will also increase the memory usage respectively.

Parameters
$outputChunkSize : int

Size in bytes.

start()

public AbstractWriter::start (
void
): void

Method which should/will be called when the writing process starts.

write()

public TempStreamWriter::write (
string $s
): void

Write content to the stream or buffer.

Parameters
$s : string