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

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.

Parameters:
pCanvasan object that hold a PDF contents stream

Definition at line 36 of file PdfContentsTokenizer.cpp.

References PoDoFo::PdfArray::begin(), PoDoFo::eLogSeverity_Information, PoDoFo::PdfArray::end(), PoDoFo::ePdfError_InvalidDataType, PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfVariant::GetArray(), PoDoFo::PdfCanvas::GetContents(), PoDoFo::PdfVecObjects::GetObject(), PoDoFo::PdfObject::GetOwner(), PoDoFo::PdfObject::HasStream(), PoDoFo::PdfVariant::IsArray(), PoDoFo::PdfVariant::IsDictionary(), PoDoFo::PdfError::LogMessage(), m_lstContents, PODOFO_RAISE_ERROR, PODOFO_RAISE_ERROR_INFO, and SetCurrentContentsStream().

    : PdfTokenizer(), m_readingInlineImgData(false)
{
    if( !pCanvas ) 
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    PdfObject* pContents = pCanvas->GetContents();
    if( pContents && pContents->IsArray()  )
    {
        PdfArray& a = pContents->GetArray();
        for ( PdfArray::iterator it = a.begin(); it != a.end() ; ++it )
        {
            if ( !(*it).IsReference() )
            {
                PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "/Contents array contained non-references" );

            }

            m_lstContents.push_back( pContents->GetOwner()->GetObject( (*it).GetReference() ) );
        }
    }
    else if ( pContents && pContents->HasStream() )
    {
        m_lstContents.push_back( pContents );
    }
    else if ( pContents && pContents->IsDictionary() )
    {
        m_lstContents.push_back( pContents );
        PdfError::LogMessage(eLogSeverity_Information,
                  "PdfContentsTokenizer: found canvas-dictionary without stream => empty page");
        // OC 18.09.2010 BugFix: Found an empty page in a PDF document:
        //    103 0 obj
        //    <<
        //    /Type /Page
        //    /MediaBox [ 0 0 595 842 ]
        //    /Parent 3 0 R
        //    /Resources <<
        //    /ProcSet [ /PDF ]
        //    >>
        //    /Rotate 0
        //    >>
        //    endobj
    }
    else
    {
        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Page /Contents not stream or array of streams" );
    }

    if( m_lstContents.size() )
    {
        SetCurrentContentsStream( m_lstContents.front() );
        m_lstContents.pop_front();
    }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index