Image Annotations issue - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Android development and PDF
  • Page:
  • 1

TOPIC: Image Annotations issue

Image Annotations issue 4 years 6 months ago #6077

  • dilawer
  • dilawer's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 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

Please Log in or Create an account to join the conversation.

Image Annotations issue 4 years 6 months ago #6081

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 846
  • Karma: 43
  • Thank you received: 12
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 following user(s) said Thank You: Haktic

Please Log in or Create an account to join the conversation.

Image Annotations issue 3 years 3 months ago #9396

  • Haktic
  • Haktic's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 16
  • Thank you received: 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

Please Log in or Create an account to join the conversation.

Image Annotations issue 3 years 3 months ago #9398

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 17
  • Thank you received: 65

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum