You can see how is GetField working:

PdfField PdfPage::GetField( int index )

{

    int            nCount  = 0;

    int            nAnnots = this->GetNumAnnots();

    PdfAnnotation* pAnnot  = NULL;

    for( int i=0;i<nAnnots;i++ )

    {

        pAnnot = this->GetAnnotation( i );

        // Count every widget annotation with a FieldType as PdfField

        if( pAnnot->GetType() == ePdfAnnotation_Widget )

        {

            if( nCount == index )

            {

                return PdfField( pAnnot->GetObject(), pAnnot );

            }

            else

                ++nCount;

        }

    }


    PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );

}

On Tue, Mar 26, 2019 at 8:49 PM Michal Sudolsky <sudols...@gmail.com> wrote:

>
>>
>>
>>  for (int i = 0; i < curPage->GetNumAnnots(); i++)
>>
>>         {
>>
>>             curAnno = curPage->GetAnnotation(i);
>>
>>             mRect = curAnno->GetRect();
>>
>>
>>
>>             PdfField curField = curPage->GetField(i);
>>
>>
> I would be cautious about calling GetField with "annotation" index. It is
> possible that there are annotations that are not acroform fields so these
> indexes would not match and there can be different number of annotations
> and acroform fields. Better would be to create curField from curAnno like I
> mentioned in my pseudo example "PdfField curField(curAnno->GetObject(),
> curAnno);". And you can also check whether is curAnno of type "widget" and
> skip if not: "if(curAnno->GetType() != ePdfAnnotation_Widget) continue;"
>
>
>
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to