Hi Team,
I am adding image annotations at pdf and for portrait mode that is working great. Please check my method below
private void drawBitmapAnnot(){
//set annotation image of page
int lc;// loop count: 2 for landscape dualpage and 1 for portrait singlepage
int orientation =getResources().getConfiguration().orientation;
//rotation is equal 0 portrait
if(orientation == Configuration.ORIENTATION_PORTRAIT)
lc = 1;
else
lc = 2;
for(int j = 0; j < lc; j++) {
int pageNo = m_pageno + j;
Toast.makeText(_context, "pageNo" + pageNo, Toast.LENGTH_SHORT).show();
try {
Page page = m_doc.GetPage(pageNo);
Log.d("PDF", ":PAGE: " + page +"annot count"+page.GetAnnotCount());
if (page.GetAnnotCount() > 0) {
for (int ac = 0; ac < page.GetAnnotCount(); ac++) {
boolean uriContainsVideoExtension = false;
if (page.GetAnnot(ac).GetURI() != null) {
String uriString = page.GetAnnot(ac).GetURI(); //page.GetAnnotURI(page.GetAnnot(ac));
String videoExtensions[] = {".mp4", ".mov", ".3gp"};
String[] splitUri = uriString.split("#");
Log.d("PDF", ":uriString: " + uriString);
// Log.d("PDF", ":uriString: " + splitUri.length);
Log.d("PDF", ":uriString: " + splitUri[0]);
for (int i = 0; i < videoExtensions.length; i++) {
uriContainsVideoExtension = uriString.toLowerCase().indexOf(videoExtensions.toLowerCase()) != -1;
// Log.d("PDF", ":uriContainsVideoExtension:" + uriContainsVideoExtension);
if (uriContainsVideoExtension)
break;
}
float rect[] = page.GetAnnot(ac).GetRect(); //new float[4];
float left = rect[0];
float top = rect[1];
rect[2] = left + iconWidth;
rect[3] = top + iconWidth;
if (uriContainsVideoExtension) {
PDFView myPDFView = this.getPDFView();
page.AddAnnotBitmap(videoIcon, true, rect);
page.AddAnnotURI(rect, uriString);
myPDFView.vRender(myPDFView.vGetPage(pageNo));
} else {
PDFView myPDFView = this.getPDFView();
page.AddAnnotBitmap(linkIcon, true, rect);
page.AddAnnotURI(rect, uriString);
myPDFView.vRender(myPDFView.vGetPage(pageNo));
}
}
}
}
}catch (NullPointerException e){
Log.d("exception in adding image annotation",e.toString());
}
}
}
The problem I am having is in landscape mode. Most of the times for the second page in landscpe mode I got ZERO for "page.GetAnnotCount()" if I am swiping from right to left. If I swipe left to right it gets ZERO for page 1. Please let me know what could be the possible issue ?
I am calling this method in "public void OnPDFPosChanged(PDFPos pos)" method of PDFReader. Any help would be appreciated.
Thanks