Im trying to initialize my pdf with some field values when the pdf loads up. Im looping through the annots using the below code :
for(int pageno = 0; pageno < m_doc.GetPageCount(); pageno++) {
page = m_doc.GetPage(pageno);
Log.e("annot count", "annot count" + page.GetAnnotCount());
// my code goes here to initialize each field.
for (int index = 0; index < page.GetAnnotCount(); index++) {
annot = page.GetAnnot(index);
}
}
But the page.GetAnnotCount is 0. What could be the reason for this? Im calling this only after setting the m_layout. And I've made sure the pdf is fully loaded before calling page.GetAnnotCount(). Please can you take a look?
Hi,
I think you are calling the GetAnnotCount() before the pdf is ready to get all the annot.
So I suggest you to start your operations after a delay, something like that:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//your code
}
}, 500);