PoDoFo  0.9.4
Public Member Functions | List of all members
PoDoFo::PdfContentsTokenizer Class Reference

#include <PdfContentsTokenizer.h>

Inheritance diagram for PoDoFo::PdfContentsTokenizer:

Public Member Functions

 PdfContentsTokenizer (const char *pBuffer, long lLen)
 PdfContentsTokenizer (PdfCanvas *pCanvas)
bool ReadNext (EPdfContentsType &reType, const char *&rpszKeyword, PoDoFo::PdfVariant &rVariant)
bool GetNextToken (const char *&pszToken, EPdfTokenType *peType=NULL)
- Public Member Functions inherited from PoDoFo::PdfTokenizer
bool IsNextToken (const char *pszToken)
pdf_long GetNextNumber ()
void GetNextVariant (PdfVariant &rVariant, PdfEncrypt *pEncrypt)

Additional Inherited Members

- Static Public Member Functions inherited from PoDoFo::PdfTokenizer
static PODOFO_NOTHROW bool IsWhitespace (const unsigned char ch)
static PODOFO_NOTHROW bool IsDelimiter (const unsigned char ch)
static PODOFO_NOTHROW bool IsRegular (const unsigned char ch)
static PODOFO_NOTHROW bool IsPrintable (const unsigned char ch)
static PODOFO_NOTHROW int GetHexValue (const unsigned char ch)
- Static Public Attributes inherited from PoDoFo::PdfTokenizer
static const unsigned int HEX_NOT_FOUND = std::numeric_limits<unsigned int>::max()
- Protected Member Functions inherited from PoDoFo::PdfTokenizer
void GetNextVariant (const char *pszToken, EPdfTokenType eType, PdfVariant &rVariant, PdfEncrypt *pEncrypt)
EPdfDataType DetermineDataType (const char *pszToken, EPdfTokenType eType, PdfVariant &rVariant)
void ReadDictionary (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadArray (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadString (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadHexString (PdfVariant &rVariant, PdfEncrypt *pEncrypt)
void ReadName (PdfVariant &rVariant)
void QuequeToken (const char *pszToken, EPdfTokenType eType)

Detailed Description

This class is a parser for content streams in PDF documents.

The parsed content stream can be used and modified in various ways.

This class is currently work in progress and subject to change!

Constructor & Destructor Documentation

PoDoFo::PdfContentsTokenizer::PdfContentsTokenizer ( const char *  pBuffer,
long  lLen 

Construct a PdfContentsTokenizer from an existing buffer. Usually a stream from a PdfPage.

pBufferpointer to a buffer
lLenlength of the buffer
PoDoFo::PdfContentsTokenizer::PdfContentsTokenizer ( PdfCanvas pCanvas)

Construct a PdfContentsTokenizer from a PdfCanvas (i.e. PdfPage or a PdfXObject).

This is more convinient as you do not have to care about buffers yourself.

pCanvasan object that hold a PDF contents stream

Member Function Documentation

bool PoDoFo::PdfContentsTokenizer::GetNextToken ( const char *&  pszToken,
EPdfTokenType *  peType = NULL 

Reads the next token from the current file position ignoring all comments.

[out]pszTokenOn true return, set to a pointer to the read token (a NULL-terminated C string). The pointer is to memory owned by PdfTokenizer and must NOT be freed. The contents are invalidated on the next call to GetNextToken(..) and by the destruction of the PdfTokenizer. Undefined on false return.
[out]peTypeOn true return, if not NULL the type of the read token will be stored into this parameter. Undefined on false return.
True if a token was read, false if there are no more tokens to read.
See also

Reimplemented from PoDoFo::PdfTokenizer.

bool PoDoFo::PdfContentsTokenizer::ReadNext ( EPdfContentsType reType,
const char *&  rpszKeyword,
PoDoFo::PdfVariant rVariant 

Read the next keyword or variant, returning true and setting reType if something was read. Either rpszKeyword or rVariant, but never both, have defined and usable values on true return, with which being controlled by the value of eType.

If EOF is encountered, returns false and leaves eType, pszKeyword and rVariant undefined.

As a special case, reType may be set to ePdfContentsType_ImageData. In this case rpszzKeyword is undefined, and rVariant contains a PdfData variant containing the byte sequence between the ID and BI keywords sans the one byte of leading- and trailing- white space. No filter decoding is performed.

[out]reTypewill be set to either keyword or variant if true is returned. Undefined if false is returned.
[out]rpszKeywordif pType is set to ePdfContentsType_Keyword this will point to the keyword, otherwise the value is undefined. If set, the value points to memory owned by the PdfContentsTokenizer and must not be freed. The value is invalidated when ReadNext is next called or when the PdfContentsTokenizer is destroyed.
[out]rVariantif pType is set to ePdfContentsType_Variant or ePdfContentsType_ImageData this will be set to the read variant, otherwise the value is undefined.