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

Create custom Annotation from coordinates

More
IP: 211.24.100.120 7 years 9 months ago #14213 by Faris
Hi support team,

I've asked around the iOS forum for something similar : -
www.radaeepdf.com/forum/ios-dev/4169-cre...ion-from-coordinates

Now, I am looking for it for Android version.

I would like to create custom rectangular annotations, based on coordinates received (x, y, height, width) , programmatically on the PDF files when the viewer started.
Would also want the annotations to be clickable to do some actions (open a new view controller / alertDialog etc.)

For example,
I would like to annotate the text like in attachment picture, and the user will be only able to click on them but can't do any editing.

Would like ask the support team whether this possible with radaeepdf kit?

Thanks in advance,
Faris
More
IP: 212.97.62.176 7 years 9 months ago #14216 by emanuele
Dear Faris,

here is a sample code also for Android version, you can use it in PDFLayoutView class:
Code:
int x = 100; int y = 100; int width = 400; int height = 100; float rect[] = new float[4]; rect[0] = x; rect[1] = y; rect[2] = rect[0] + width; rect[3] = rect[1] + height; PDFPos pos = m_layout.vGetPos(0, 0);//where rect is in screen coordinate. VPage vpage = m_layout.vGetPage(pos.pageno); Matrix mat = vpage.CreateInvertMatrix(m_layout.vGetX(), m_layout.vGetY()); mat.TransformRect(rect); Page page = m_doc.GetPage(0); page.AddAnnotRect(rect, vpage.ToPDFSize(Global.rect_annot_width), Global.rect_annot_color, Global.rect_annot_fill_color); mat.Destroy(); PDFUpdateCurrPage();

About action on annot click you can use the same logic of iOS version, using OnAnnotClicked method, implemented in PDFReaderAct class
More
IP: 211.24.100.120 7 years 9 months ago #14225 by afarhan39
Hi Emanuele,

I managed to use RadaeePDF to display PDF.
Code:
RadaeePDFManager radaeePDFManager = new RadaeePDFManager(); File file = new File(context.getFilesDir(), Utils.modFileName(epaperItem.getName())); radaeePDFManager.openFromPath(context, file.getAbsolutePath(), "");

Similar to Faris, I also want to draw custom rectangular annotations based on coordinates received (x, y, height, width).
I have looked into your answer, but I confused on how to implement it.
On each page have different rectangular annotations, and I have like around 40+ pages to annotate.
How do I call this function?
Would love to receive some helps.
More
IP: 212.97.62.176 7 years 9 months ago #14227 by emanuele
Hi,

you can add a new method in PDFLayoutView class with the code of my previous post.
In my example I used static x, y, width, height and the current page to add the annotation, but you can edit the code and use variables to add the annotation on your page taking x, y, width, height and page as input parameters, than add a for cycle to call the function for each needed page.
More
IP: 211.24.100.120 7 years 9 months ago #14228 by afarhan39
Hi Emanuele,
Thanks for the fast response.

For now I'm using AboutActivity in demo Android that RadaeePDF provided, since it the only one I see have PDFLayoutView in use.
I tried based on your suggestion, which to add new function A to draw rect.
I tried and error on which method shall I call this function A, since I don't really know where shall I call this.
void OnPDFPageModified(int pageno);
void OnPDFPageChanged(int pageno);
void OnPDFPageDisplayed(Canvas canvas, IVPage vpage);
void OnPDFPageRendered(IVPage vpage);
But none of them show the rectangle.
Further checking the method, I found out the method page.AddAnnotRect(..) return false. What does it means?

TLDR
1. Where shall I call your code mention?
2. Why does page.AddAnnotRect(...) return false?
More
IP: 212.97.62.176 7 years 9 months ago - 7 years 9 months ago #14232 by emanuele
First of all, I suggest to use PDFViewController class (contained in PDFViewAct), as it implements all methods and callbacks.
Now you can choose the event where you will call your new method, for example you can check it with OnBlankTapped method, triggered where you tap on the pdf.
AboutActivity is used only to show the "about" info, for that reason it doesn't contain the toolbar.
Last edit: 7 years 9 months ago by emanuele.
Time to create page: 0.442 seconds
Powered by Kunena Forum