Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

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

Definition at line 186 of file PdfStream.cpp.

References PoDoFo::PdfDictionary::AddKey(), Append(), PoDoFo::PdfArray::begin(), BeginAppendImpl(), PoDoFo::PdfVecObjects::BeginAppendStream(), PoDoFo::PdfFilterFactory::FilterTypeToName(), PoDoFo::PdfVariant::GetDictionary(), GetFilteredCopy(), GetLength(), PoDoFo::PdfObject::GetOwner(), PODOFO_RAISE_LOGIC_IF, PoDoFo::PdfArray::push_back(), and PoDoFo::PdfDictionary::RemoveKey().

{
    char* pBuffer = NULL;
    pdf_long lLen = 0; //RG: TODO Should this variable be initialised with 0 (line 225 may fall through without initialisation!)

    PODOFO_RAISE_LOGIC_IF( m_bAppend, "BeginAppend() failed because EndAppend() was not yet called!" );

    if( m_pParent && m_pParent->GetOwner() )
        m_pParent->GetOwner()->BeginAppendStream( this );

    if( !bClearExisting && this->GetLength() ) 
        this->GetFilteredCopy( &pBuffer, &lLen );

    if( !vecFilters.size() && bDeleteFilters )
    {
        m_pParent->GetDictionary().RemoveKey( PdfName::KeyFilter );
    }
    if( vecFilters.size() == 1 )
    {
        m_pParent->GetDictionary().AddKey( PdfName::KeyFilter, 
                                           PdfName( PdfFilterFactory::FilterTypeToName( vecFilters.front() ) ) );
    }
    else if( vecFilters.size() > 1 )
    {
        PdfArray filters;
        TCIVecFilters it = vecFilters.begin();
        while( it != vecFilters.end() )
        {
            filters.push_back( PdfName( PdfFilterFactory::FilterTypeToName( *it ) ) );
            ++it;
        }
        
        m_pParent->GetDictionary().AddKey( PdfName::KeyFilter, filters );
    }

    this->BeginAppendImpl( vecFilters );
    m_bAppend = true;
    if( pBuffer ) 
    {
        this->Append( pBuffer, lLen );
        free( pBuffer );
    }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index