pdfmm 0.9.20
Public Member Functions | Protected Member Functions | List of all members
mm::PdfFileStream Class Referencefinal

#include <PdfFileStream.h>

Inheritance diagram for mm::PdfFileStream:
mm::PdfStream

Public Member Functions

 PdfFileStream (PdfObject &parent, PdfOutputDevice &device)
 
void SetEncrypted (PdfEncrypt *encrypt)
 
void Write (PdfOutputDevice &device, const PdfEncrypt *encrypt) override
 
void GetCopy (std::unique_ptr< char[]> &buffer, size_t &len) const override
 
void GetCopy (PdfOutputStream &stream) const override
 
size_t GetLength () const override
 
- Public Member Functions inherited from mm::PdfStream
virtual void Write (PdfOutputDevice &device, const PdfEncrypt *encrypt)=0
 
void Set (const std::string_view &view, const PdfFilterList &filters)
 
void Set (const char *buffer, size_t len, const PdfFilterList &filters)
 
void Set (const std::string_view &view)
 
void Set (const char *buffer, size_t len)
 
void Set (PdfInputStream &stream)
 
void Set (PdfInputStream &stream, const PdfFilterList &filters)
 
void SetRawData (PdfInputStream &stream, ssize_t len=-1)
 
void BeginAppend (bool clearExisting=true)
 
void BeginAppend (const PdfFilterList &filters, bool clearExisting=true, bool deleteFilters=true)
 
PdfStreamAppend (const std::string_view &view)
 
PdfStreamAppend (const char *buffer, size_t len)
 
void EndAppend ()
 
bool IsAppending () const
 
virtual size_t GetLength () const =0
 
virtual void GetCopy (std::unique_ptr< char[]> &buffer, size_t &len) const =0
 
virtual void GetCopy (PdfOutputStream &stream) const =0
 
void GetFilteredCopy (std::unique_ptr< char[]> &buffer, size_t &len) const
 
void GetFilteredCopy (PdfOutputStream &stream) const
 
const PdfStreamoperator= (const PdfStream &rhs)
 

Protected Member Functions

const char * GetInternalBuffer () const override
 
size_t GetInternalBufferSize () const override
 
void BeginAppendImpl (const PdfFilterList &filters) override
 
void AppendImpl (const char *data, size_t len) override
 
void EndAppendImpl () override
 
- Protected Member Functions inherited from mm::PdfStream
 PdfStream (PdfObject &parent)
 
virtual const char * GetInternalBuffer () const =0
 
virtual size_t GetInternalBufferSize () const =0
 
virtual void BeginAppendImpl (const PdfFilterList &filters)=0
 
virtual void AppendImpl (const char *data, size_t len)=0
 
virtual void EndAppendImpl ()=0
 

Additional Inherited Members

- Static Public Attributes inherited from mm::PdfStream
static enum PdfFilterType DefaultFilter
 

Detailed Description

A PDF stream can be appended to any PdfObject and can contain arbitrary data.

Most of the time it will contain either drawing commands to draw onto a page or binary data like a font or an image.

A PdfFileStream writes all data directly to an output device without keeping it in memory. PdfFileStream is used automatically when creating PDF files using PdfImmediateWriter.

See also
PdfIndirectObjectList
PdfStream
PdfMemoryStream
PdfFileStream

Constructor & Destructor Documentation

◆ PdfFileStream()

PdfFileStream::PdfFileStream ( PdfObject parent,
PdfOutputDevice device 
)

Create a new PdfFileStream object which has a parent PdfObject. The stream will be deleted along with the parent. This constructor will be called by PdfObject::Stream() for you.

Parameters
parentparent object
deviceoutput device

Member Function Documentation

◆ AppendImpl()

void PdfFileStream::AppendImpl ( const char *  data,
size_t  len 
)
overrideprotectedvirtual

Append a binary buffer to the current stream contents.

Parameters
dataa buffer
lenlength of the buffer
See also
BeginAppend
Append
EndAppend

Implements mm::PdfStream.

◆ BeginAppendImpl()

void PdfFileStream::BeginAppendImpl ( const PdfFilterList &  filters)
overrideprotectedvirtual

Begin appending data to this stream. Clears the current stream contents.

Use PdfFilterFactory::CreateFilterList() if you want to use the contents of the stream dictionary's existing filter key.

Parameters
filtersuse these filters to encode any data written to the stream.

Implements mm::PdfStream.

◆ EndAppendImpl()

void PdfFileStream::EndAppendImpl ( )
overrideprotectedvirtual

Finish appending data to the stream

Implements mm::PdfStream.

◆ GetCopy() [1/2]

void PdfFileStream::GetCopy ( PdfOutputStream stream) const
overridevirtual

Get a copy of a the stream and write it to a PdfOutputStream

Parameters
streamdata is written to this stream.

Implements mm::PdfStream.

◆ GetCopy() [2/2]

void mm::PdfFileStream::GetCopy ( std::unique_ptr< char[]> &  buffer,
size_t &  len 
) const
overridevirtual

Get a malloc()'d buffer of the current stream. No filters will be applied to the buffer, so if the stream is Flate-compressed the compressed copy will be returned.

The caller has to the buffer.

Parameters
bufferpointer to the buffer
lenpointer to the buffer length

Implements mm::PdfStream.

◆ GetInternalBuffer()

const char * PdfFileStream::GetInternalBuffer ( ) const
overrideprotectedvirtual

Required for the GetFilteredCopy() implementation

Returns
a handle to the internal buffer

Implements mm::PdfStream.

◆ GetInternalBufferSize()

size_t PdfFileStream::GetInternalBufferSize ( ) const
overrideprotectedvirtual

Required for the GetFilteredCopy() implementation

Returns
the size of the internal buffer

Implements mm::PdfStream.

◆ GetLength()

size_t PdfFileStream::GetLength ( ) const
overridevirtual

Get the stream's length with all filters applied (e.g. if the stream is Flate-compressed, the length of the compressed data stream).

Returns
the length of the internal buffer

Implements mm::PdfStream.

◆ SetEncrypted()

void PdfFileStream::SetEncrypted ( PdfEncrypt encrypt)

Set an encryption object which is used to encrypt all data written to this stream.

Parameters
encryptan encryption object or nullptr if no encryption should be done

◆ Write()

void PdfFileStream::Write ( PdfOutputDevice device,
const PdfEncrypt encrypt 
)
overridevirtual

Write the stream to an output device

Parameters
devicewrite to this outputdevice.
encryptencrypt stream data using this object

Implements mm::PdfStream.