PoDoFo  0.9.4
Public Member Functions | Protected Member Functions | List of all members
PoDoFo::PdfStream Class Referenceabstract

#include <PdfStream.h>

Inheritance diagram for PoDoFo::PdfStream:
PoDoFo::PdfFileStream PoDoFo::PdfMemStream

Public Member Functions

 PdfStream (PdfObject *pParent)
 
virtual void Write (PdfOutputDevice *pDevice, PdfEncrypt *pEncrypt=NULL)=0
 
void Set (const char *szBuffer, pdf_long lLen, const TVecFilters &vecFilters)
 
void Set (const char *szBuffer, pdf_long lLen)
 
void Set (PdfInputStream *pStream)
 
void Set (PdfInputStream *pStream, const TVecFilters &vecFilters)
 
void Set (const char *pszString)
 
void SetRawData (PdfInputStream *pStream, pdf_long lLen=-1)
 
void BeginAppend (bool bClearExisting=true)
 
void BeginAppend (const TVecFilters &vecFilters, bool bClearExisting=true, bool bDeleteFilters=true)
 
void Append (const char *pszString, size_t lLen)
 
void Append (const char *pszString)
 
void Append (const std::string &sString)
 
void EndAppend ()
 
bool IsAppending () const
 
virtual pdf_long GetLength () const =0
 
virtual void GetCopy (char **pBuffer, pdf_long *lLen) const =0
 
virtual void GetCopy (PdfOutputStream *pStream) const =0
 
void GetFilteredCopy (char **pBuffer, pdf_long *lLen) const
 
void GetFilteredCopy (PdfOutputStream *pStream) const
 
const PdfStreamoperator= (const PdfStream &rhs)
 

Protected Member Functions

virtual const char * GetInternalBuffer () const =0
 
virtual pdf_long GetInternalBufferSize () const =0
 
virtual void BeginAppendImpl (const TVecFilters &vecFilters)=0
 
virtual void AppendImpl (const char *pszString, size_t lLen)=0
 
virtual void EndAppendImpl ()=0
 

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.

You have to use a concrete implementation of a stream, which can be retrieved from a StreamFactory.

See also
PdfVecObjects
PdfMemoryStream
PdfFileStream

Constructor & Destructor Documentation

PoDoFo::PdfStream::PdfStream ( PdfObject pParent)

Create a new PdfStream 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
pParentparent object

Member Function Documentation

void PoDoFo::PdfStream::Append ( const char *  pszString,
size_t  lLen 
)
inline

Append a binary buffer to the current stream contents.

Make sure BeginAppend() has been called before.

Parameters
pszStringa buffer
lLenlength of the buffer
See also
BeginAppend
EndAppend
void PoDoFo::PdfStream::Append ( const char *  pszString)
inline

Append a null-terminated string to the current stream contents.

Make sure BeginAppend() has been called before.

Parameters
pszStringa zero-terminated string buffer containing only ASCII text data
See also
BeginAppend
EndAppend
void PoDoFo::PdfStream::Append ( const std::string &  sString)
inline

Append to the current stream contents.

Make sure BeginAppend() has been called before.

Parameters
sStringa std::string containing only ASCII text data
See also
BeginAppend
EndAppend
virtual void PoDoFo::PdfStream::AppendImpl ( const char *  pszString,
size_t  lLen 
)
protectedpure virtual

Append a binary buffer to the current stream contents.

Parameters
pszStringa buffer
lLenlength of the buffer
See also
BeginAppend
Append
EndAppend

Implemented in PoDoFo::PdfMemStream, and PoDoFo::PdfFileStream.

void PoDoFo::PdfStream::BeginAppend ( bool  bClearExisting = true)

Start appending data to this stream.

This method has to be called before any of the append methods. All appended data will be Flate-encoded.

Parameters
bClearExistingif true any existing stream contents will be cleared.
See also
Append
EndAppend
void PoDoFo::PdfStream::BeginAppend ( const TVecFilters &  vecFilters,
bool  bClearExisting = true,
bool  bDeleteFilters = true 
)

Start appending data to this stream. This method has to be called before any of the append methods.

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

Parameters
vecFiltersa list of filters to use when appending data
bClearExistingif true any existing stream contents will be cleared.
bDeleteFiltersif true existing filter keys are deleted if an empty list of filters is passed (required for SetRawData())
See also
Append
EndAppend
virtual void PoDoFo::PdfStream::BeginAppendImpl ( const TVecFilters &  vecFilters)
protectedpure virtual

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
vecFiltersuse these filters to encode any data written to the stream.

Implemented in PoDoFo::PdfMemStream, and PoDoFo::PdfFileStream.

void PoDoFo::PdfStream::EndAppend ( )

Finish appending data to this stream. BeginAppend() has to be called before this method.

See also
BeginAppend
Append
virtual void PoDoFo::PdfStream::EndAppendImpl ( )
protectedpure virtual

Finish appending data to the stream

Implemented in PoDoFo::PdfMemStream, and PoDoFo::PdfFileStream.

virtual void PoDoFo::PdfStream::GetCopy ( char **  pBuffer,
pdf_long *  lLen 
) const
pure virtual

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 podofo_free() the buffer.

Parameters
pBufferpointer to the buffer
lLenpointer to the buffer length

Implemented in PoDoFo::PdfFileStream, and PoDoFo::PdfMemStream.

virtual void PoDoFo::PdfStream::GetCopy ( PdfOutputStream pStream) const
pure virtual

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

Parameters
pStreamdata is written to this stream.

Implemented in PoDoFo::PdfFileStream, and PoDoFo::PdfMemStream.

void PoDoFo::PdfStream::GetFilteredCopy ( char **  pBuffer,
pdf_long *  lLen 
) const

Get a malloc()'d buffer of the current stream which has been filtered by all filters as specified in the dictionary's /Filter key. For example, if the stream is Flate-compressed, the buffer returned from this method will have been decompressed.

The caller has to podofo_free() the buffer.

Parameters
pBufferpointer to the buffer
lLenpointer to the buffer length
void PoDoFo::PdfStream::GetFilteredCopy ( PdfOutputStream pStream) const

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

Parameters
pStreamfiltered data is written to this stream.
virtual const char* PoDoFo::PdfStream::GetInternalBuffer ( ) const
protectedpure virtual

Required for the GetFilteredCopy() implementation

Returns
a handle to the internal buffer

Implemented in PoDoFo::PdfMemStream, and PoDoFo::PdfFileStream.

virtual pdf_long PoDoFo::PdfStream::GetInternalBufferSize ( ) const
protectedpure virtual

Required for the GetFilteredCopy() implementation

Returns
the size of the internal buffer

Implemented in PoDoFo::PdfMemStream, and PoDoFo::PdfFileStream.

virtual pdf_long PoDoFo::PdfStream::GetLength ( ) const
pure virtual

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

Implemented in PoDoFo::PdfMemStream, and PoDoFo::PdfFileStream.

bool PoDoFo::PdfStream::IsAppending ( ) const
inline
Returns
true if code is between BeginAppend() and EndAppend() at the moment, i.e. it is safe to call EndAppend() now.
See also
BeginAppend
Append
const PdfStream & PoDoFo::PdfStream::operator= ( const PdfStream rhs)

Create a copy of a PdfStream object

Parameters
rhsthe object to clone
Returns
a reference to this object
void PoDoFo::PdfStream::Set ( const char *  szBuffer,
pdf_long  lLen,
const TVecFilters &  vecFilters 
)

Set a binary buffer as stream data.

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

Parameters
szBufferbuffer containing the stream data
lLenlength of the buffer
vecFiltersa list of filters to use when appending data
void PoDoFo::PdfStream::Set ( const char *  szBuffer,
pdf_long  lLen 
)

Set a binary buffer as stream data. All data will be Flate-encoded.

Parameters
szBufferbuffer containing the stream data
lLenlength of the buffer
void PoDoFo::PdfStream::Set ( PdfInputStream pStream)

Set a binary buffer whose contents are read from a PdfInputStream All data will be Flate-encoded.

Parameters
pStreamread stream contents from this PdfInputStream
void PoDoFo::PdfStream::Set ( PdfInputStream pStream,
const TVecFilters &  vecFilters 
)

Set a binary buffer whose contents are read from a PdfInputStream

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

Parameters
pStreamread stream contents from this PdfInputStream
vecFiltersa list of filters to use when appending data
void PoDoFo::PdfStream::Set ( const char *  pszString)
inline

Set a null-terminated char* buffer as the stream's contents.

The string will be copied into a newly allocated buffer.

Parameters
pszStringa zero terminated string buffer containing only ASCII text data
void PoDoFo::PdfStream::SetRawData ( PdfInputStream pStream,
pdf_long  lLen = -1 
)

Sets raw data for this stream which is read from an input stream. This method does neither encode nor decode the read data. The filters of the object are not modified and the data is expected encoded as stated by the /Filters key in the stream's object.

Parameters
pStreamread data from this input stream
lLenread exactly lLen bytes from the input stream, if lLen = -1 read until the end of the input stream was reached.
virtual void PoDoFo::PdfStream::Write ( PdfOutputDevice pDevice,
PdfEncrypt pEncrypt = NULL 
)
pure virtual

Write the stream to an output device

Parameters
pDevicewrite to this outputdevice.
pEncryptencrypt stream data using this object

Implemented in PoDoFo::PdfFileStream, and PoDoFo::PdfMemStream.