RadaeePDF.com :: Topic: Image Annotations issue (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF

TOPIC: Image Annotations issue

Image Annotations issue 3 years 2 months ago #6077

  • dilawer
  • dilawer's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
  • Karma: 0
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
The administrator has disabled public write access.

Image Annotations issue 3 years 2 months ago #6081

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
in this time, the Page object not loaded.
to works:
--get Page object by yourself in Document object, like m_doc.GetPage(pageno).
--invoke Page.ObjsStart();
--add annotations.
--invoke Page.Close()(Page object obtained from m_doc.GetPage(pageno))
--invoke PDFView.vRenderPage()...
The administrator has disabled public write access.
The following user(s) said Thank You: Haktic

Image Annotations issue 1 year 11 months ago #9396

  • Haktic
  • Haktic's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 16
  • Karma: 0
radaee
Thanks for you solution and that was worked well, but i am getting problem, My image annotations are working fine, but once i close the page and then open again .., links works fine but image didn't show up again. Can you please suggest a solution? THanks in advance
The administrator has disabled public write access.

Image Annotations issue 1 year 11 months ago #9398

  • Davide
  • Davide's Avatar
  • OFFLINE
  • Moderator
  • Posts: 663
  • Thank you received: 43
  • Karma: 12
The administrator has disabled public write access.
Powered by Kunena Forum