Skip to main content
Participant
July 26, 2022
Question

IAC C# using GetAnnotIndex and GetAnnot Method

  • July 26, 2022
  • 1 reply
  • 757 views

How can I find the index of an annotation ? 

int annotIndex = pDPage.GetAnnotIndex(pDAnnot);

 

For getting the pDAnnot, we need to specify the index before hand 

pDAnnot = (CAcroPDAnnot)pDPage.GetAnnotIndex(annotIndex);

Feels like a closed loop. Any idea on how to get AnnotationIndex

 

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
July 26, 2022

Use a loop over all annotations.

Participant
July 27, 2022

NOTE : There is an error in the code in above Q . Below is the correct code.

pDAnnot = (CAcroPDAnnot)pDPage.GetAnnot(annotIndex);

Coing back to  discussion , how can I do that ?

pDAnnot is not iterable in this specific case as it fetches single pDAnnot Object.

However, I can do a loop like this, but i see no upside to it.

for (int i = 0; i < pDPage.GetNumAnnots(); i++)
{
   pDAnnot = (CAcroPDAnnot)pDPage.GetAnnot(i);
   int j = pDPage.GetAnnotIndex(pDAnnot);
   // j & i will be same
}

 

Its like,

For getting annotation object (pDAnnot) you need to provide anootationIndex .

For getting anootationIndex , you need to provide ano\notation object(pDAnnot)

Am I missing something here ?

Bernd Alheit
Community Expert
Community Expert
July 27, 2022

For what annotation want you the index?