We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Custom Appearance for PDF Annotation

Hi, I need to create several annotations in PDF file with custom appearance… for example a line annotation with a small rectangle added:
grafik.png (2.1 KB)

Or some circle annotation:
grafik.png (9.7 KB)

Or some rectangle annotation:
grafik.png (7.5 KB)

I suspect that for such custom display of annotation I need to use the Appearance dictionary BUT unfortunately I don’t have any idea on how to do that.

Please help.
Thanks in advance.

Best Regards


Can you please share which API are you using e.g. .NET/Java? We will try to prepare a code snippet in order to achieve your requirements and share it with you.

Yes, I am using the latests Aspose Total for .NET API. Thank you very much.


We are trying to write a code example to achieve your requirements and will get back to you shortly.

1 Like

@asad.ali Can you please give me an estimate when such code example will be available?


Thanks for your patience.

Please note that there is no single annotation in the API which can add a rectangle and arrow on the page. Instead, you need to draw a rectangle separately and then add a line annotation (with arrow head) to connect with added rectangle. For example, please check in the below code snippet and feel free to let us know in case you need further information:

Document mRes = new Document();
Page page = mRes.Pages[1];
page.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
// Draw canvas according to page height/widht where shapes will be added
var canvas = new Aspose.Pdf.Drawing.Graph((float)mRes.PageInfo.Width, (float)mRes.PageInfo.Height);
Aspose.Pdf.Drawing.Rectangle myRec = new Aspose.Pdf.Drawing.Rectangle(0, 738, 180, 100);
var c = ColorTranslator.FromHtml("#0099ff");
myRec.GraphInfo.Color = Aspose.Pdf.Color.FromRgb(c);
myRec.Text = new TextFragment("Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum");
myRec.Text.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(c);

// Start point where the above rectangle's right-bottom corner ends i.e. x = 180, y = 738
Point startH = new Point(myRec.Width, myRec.Bottom);
// End Point for how long and in which direction the line arrow should point to e.g. x = 180+300, y = 738 - 100
Point endH = new Point(myRec.Width + 300, myRec.Bottom - 100);

// DrawArrow
LineAnnotation line2 = new LineAnnotation(page, new Rectangle(180, 738, 480, 638), startH, endH)
 Intent = LineIntent.LineDimension,
 Color = Aspose.Pdf.Color.Black,
 EndingStyle = LineEnding.OpenArrow,
 StartingStyle = LineEnding.None
Border border2 = new Border(line2);
border2.Width = 2;
line2.Border = border2;

mRes.Save(dataDir + "RectangleAndArrow.pdf");