How to add custom annotation with help of Rect points in pdf doc?

Product:PDFTron Android SDK

Product Version:Latest

Please give a brief summary of your issue:How to add custom annotation ( any image or icon ) with help of Rect points in pdf doc?
(Think of this as an email subject)

Please describe your issue and provide steps to reproduce it:
I want to create a custom annotation like Image pinning at particular position in pdf doc.
So how can I add this created custom annotation in pdf doc using Rect points & when i tap on it, how could i get the annotation properties & position in pdf doc?
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:


If you would like to create a custom annotation for an image/icon you can use our Stamper class to achieve this. Please see here for more information:

In the above example we use “PDFDoc doc = new PDFDoc(filename);”.
If you are using PdfViewCtrlTabHostFragment2, you can call hostFragment.getCurrentPdfViewCtrlFragment().getPdfDoc() to get the PDFDoc.

Hi Emallon,
Thanks for the answer & reply. Stamper class works for me.
I have used like
val s = Stamper(Stamper.e_relative_scale, .05, .05)
I want to select this stamp & move across the pdf but i don’t need to show the quick action popup when i select this stamp.
I am using “PDFDoc doc = new PDFDoc(filename);”.
Please help with suggestion how can i archive this.



I will reply to this on your other thread on this topic : here

Best Regards,


I have created Custom Annotation using stamper class. My app requirement is the size of stamp annotation should be same when i zoom in or zoom out. The stamp size should not vary as per pdf document zooming. Is there any way to fix the size of custom annotation even in zoom in?

I have attached two images, how it looks now. Here, the annotation size is increasing when i do zoom in.

Hi Manoj,

Based on what you described, what you really need is a sticky note type annotation with custom appearance.
We have a sample project here: pdftron-android-samples/CustomStickyNote at master · PDFTron/pdftron-android-samples · GitHub

In this sample, it shows how to add a sticky note with custom appearance. Sticky note by default will have the same size when zoom in/out.

Could you please give it a try?

Hi Shirley,

Thanks for the reply. I have gone through the sticky note git hub sample. From here, I could not find how we can customise appearance of sticky note.

I have tried with some code

val s = StickyNoteCreate(mPdfViewCtrl!!)
s.setTargetPoint(PointF(100f, 200f))
val bitmap = getBitmapFromVectorDrawable(R.drawable.ic_issue_pin)
val img = getBase64String(bitmap)

There are few queries i have,

  1. Here, for icon the param is expecting string. Is this the method, we can change icon. If yes, what should i pass as string for customise icon.
  2. After create this annotation, edit popup is showing automatically.
    My app does not need pop-up when i set ‘setTargetPoint()’ . Could i hide the popup?

Hi Manoj,

For adding custom annotation as you described, it’s better to use custom annotation appearance:

So, there are 2 options:

  1. Using element builder to create the custom appearance
  2. Create a 1 page PDF document with appearance and use that PDF as appearance

Could you please let us know which approach you are going to use? And then we can provide more information for you.

Best Regards,

Hi ,
Thanks for the reply & answer. I have used Text annotation ( Text.create(doc, Point(100.0, 100.0)) ) with custom appearance, it matches the expectation.

Is there any way to differentiate this custom annotation & Note annotation as i am getting “Annot.type” is same for both cases?

Hi Monaj,

Thanks for letting us know.
To differentiate the custom annotations, you can use setCustomData method as API documentation:,%20java.lang.String)

Could you please give it try?

Best regards,
Saeed Bazzaz