I really appreciate your quick response, but that didn't worked well, please let me know if i am adding this on the right place, Here's my function to add the Bitmap Annotations:
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;
try {
PDFVPage vpage = m_view.vGetPage(pageNo);
// if( vpage != null ) {
Page page = vpage.GetPage();//get page from PDFVPage, in this case, Page object no need to close.
int annotCount = page.GetAnnotCount();
if (page.GetAnnotCount() > 0) {
for (int ac = 0; ac < annotCount; ac++) {
boolean uriContainsVideoExtension = false;
page.ObjsStart();
Annotation annot = page.GetAnnot(ac);
if (annot.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[0]);
for (int i = 0; i < videoExtensions.length; i++) {
uriContainsVideoExtension = uriString.toLowerCase().indexOf(videoExtensions.toLowerCase()) != -1;
if (uriContainsVideoExtension)
break;
}
float rect[] = page.GetAnnot(ac).GetRect(); //new float[4];
float rect_dib[] = new float[4];
Matrix mat = new Matrix(1, 1, 0, m_doc.GetPageHeight(m_cur_page));
Global.ToDIBRect(mat, rect, rect_dib);//mat is Matrix object that passed to Page.Render() or Page.RenderToBmp()
float left = rect[0];
float top = rect[1];
float right = rect[2];
float bottom = rect[3];
float anWidth = right - left;
float anHeight = bottom - top;
Log.d("PDF", "moi schaun: ");
Log.d("PDF", " - left: " + left);
Log.d("PDF", " - right: " + right);
float xOffset = (anWidth - iconWidth) / 2;
float yOffset = (anHeight - iconWidth) / 2;
if (splitUri.length > 1) {
Log.d("PDF", " - xOffset: " + xOffset);
Log.d("PDF", " - #pos: " + splitUri[1]);
if (splitUri[1].equals("tl")) {
xOffset = 0;
yOffset = (anHeight - iconWidth);
}
if (splitUri[1].equals("tc")) {
xOffset = (anWidth - iconWidth) / 2;
yOffset = (anHeight - iconWidth);
}
if (splitUri[1].equals("tr")) {
xOffset = anWidth - iconWidth;
yOffset = (anHeight - iconWidth);
}
if (splitUri[1].equals("cl")) {
xOffset = 0;
yOffset = -(anHeight - iconWidth) / 2;
}
if (splitUri[1].equals("cr")) {
xOffset = anWidth - iconWidth;
yOffset = -(anHeight - iconWidth) / 2;
}
if (splitUri[1].equals("bl")) {
xOffset = 0;
yOffset = 0;
}
if (splitUri[1].equals("bc")) {
xOffset = (anWidth - iconWidth) / 2;
yOffset = 0;
}
if (splitUri[1].equals("br")) {
xOffset = anWidth - iconWidth;
yOffset = 0;
}
}
left = rect[0];
top = rect[1];
rect[0] = left + xOffset;
rect[1] = top + yOffset;
rect[2] = rect[0] + iconWidth;
rect[3] = rect[1] + iconWidth;
if (uriContainsVideoExtension) {
Boolean flag=page.AddAnnotBitmap(videoIcon, false, rect);
page.AddAnnotURI(rect, uriString);
} else {
Boolean flag =page.AddAnnotBitmap(linkIcon, false, rect);
page.AddAnnotURI(rect, uriString);
}
}
}
page.Close();
m_view.vRenderAsync(m_view.vGetPage(pageNo));
page.ObjsStart();
m_doc.Save();
}
}catch (NullPointerException e){
Log.d("exception in adding image annotation",e.toString());
}
}
}
Annotation Image loads perfect for first time when i see the pdf but once i close and open again, links works fine but image didn't show up.
Also the color of rectangle for annotation where the image should display get darker blue on each loading means it loads again and again. can you please suggest ? thansk