- Posts: 7
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Image Annotations issue
IP: 192.168.0.71
11 years 10 months ago #6077
by dilawer
Image Annotations issue was created by dilawer
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
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
IP: 192.168.0.71
11 years 10 months ago #6081
by radaee
Replied by radaee on topic Image Annotations issue
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()...
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()...
10 years 7 months ago #9396
by Haktic
Replied by Haktic on topic Image Annotations issue
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
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
10 years 7 months ago #9398
by Davide
Replied by Davide on topic Image Annotations issue
Hi,
look at this: www.radaeepdf.com/forum/Android-developm...-not-show-image#9397
look at this: www.radaeepdf.com/forum/Android-developm...-not-show-image#9397
Time to create page: 0.403 seconds