Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8266 Reply

    Darek

    Hello, I’ve created custom annotation which draws a circle and it works perfectly, but when I try to add button nothing is displayed. Below is my code.

    Custom annotation code:

    The way in which I add annotation:

    `
    PageView pageView = (PageView) viewer.getReaderView().getPlugPDFDisplay().getPageView();

    CustomAnnot customAnnot = new CustomAnnot(MainActivity.this, “CUSTOM”);
    customAnnot.setPageIdx(pageView.getPageIdx());
    customAnnot.setScale(pageView.getAnnotScale());
    customAnnot.setBBox(r.left, r.top, r.right, r.bottom);
    customAnnot.setObjID(12);

    pageView.addAnnot(customAnnot);
    customAnnot.invalidate();

    What I’m doing wrong?

    #8270 Reply

    Dr. Plug
    Moderator

    Hi Darek,

    Thanks very much for interest in the PlugPDF. Actually I tried using to your code. First, your code has an exception on line 17. So I had fixed it. In so doing, it is work fine without button. I think you can fix by adding below code in the CustomAnnot.

    Actually PageView is call it method often. Then every time, your button will be hidden. Therefore, you needs call same method to button also.

    Thank you,
    Dr. Plug

    #8272 Reply

    Darek

    Thanks for answer. Missed out the exception and with bringToFront works excellent. I have now one issue, when I go to the third page and go back to the first the annotation is missing, how to restore annotation without adding it again?

    #8277 Reply

    Dr. Plug
    Moderator

    Hi Darek,

    Thank you for your feedback. But it can’t normally add. Because that method is just only attach annotation to the current view. I think you should make a SparseArray and your annotation add to there, and after your page loaded, then you set again annotation from SparseArray. You can receive ‘onPageLoadFinish’ event via PageView Listener.

    Best Regards,
    Dr. Plug

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: [Android] Display custom annotation
Your information: