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

PdfAnnotation * PoDoFo::PdfPage::GetAnnotation ( int  index )

Get the annotation with index index of the current page.

Parameters:
indexthe index of the annotation to retrieve
Returns:
a annotation object. The annotation object is owned by the PdfPage.
See also:
GetNumAnnots

Definition at line 311 of file PdfPage.cpp.

References PoDoFo::PdfError::DebugMessage(), PoDoFo::ePdfError_InvalidDataType, PoDoFo::ePdfError_NoObject, PoDoFo::ePdfError_ValueOutOfRange, PoDoFo::PdfReference::GenerationNumber(), GetAnnotationsArray(), PoDoFo::PdfVariant::GetArray(), PoDoFo::PdfVecObjects::GetObject(), PoDoFo::PdfElement::GetObject(), PoDoFo::PdfObject::GetOwner(), PoDoFo::PdfVariant::IsArray(), PoDoFo::PdfReference::ObjectNumber(), PODOFO_RAISE_ERROR, and PoDoFo::PdfArray::size().

Referenced by GetField(), and GetNumFields().

{
    PdfAnnotation* pAnnot;
    PdfReference   ref;

    PdfObject*     pObj   = this->GetAnnotationsArray( false );

    if( !(pObj && pObj->IsArray()) )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
    }
    
    if( index < 0 && static_cast<unsigned int>(index) >= pObj->GetArray().size() )
    {
        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
    }

    ref    = pObj->GetArray()[index].GetReference();
    pAnnot = m_mapAnnotations[ref];
    if( !pAnnot )
    {
        pObj = this->GetObject()->GetOwner()->GetObject( ref );
        if( !pObj )
        {
            PdfError::DebugMessage( "Error looking up object %i %i R\n", ref.ObjectNumber(), ref.GenerationNumber() );
            PODOFO_RAISE_ERROR( ePdfError_NoObject );
        }
     
        pAnnot = new PdfAnnotation( pObj, this );
        m_mapAnnotations[ref] = pAnnot;
    }

    return pAnnot;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index