How do I hide just the rectangle border of a Callout annotation?

Question:

I want to have a Callout annotation that has the arrow, and the text, but not the rectangular border around the text.

How do I remove that?

Answer:
Unfortunately the PDF standard does not support this, so there is no API for it. For instance, if you did this, and then later someone resized or changed the color/text of the annotation in another PDF viewer, the rectangle border would re-appear.

However, you can edit the default appearance made by PDFTron, so that until someone changes it, which might never happen, it will not have the border as you want.

The code is below, based off of this other forum post.
https://groups.google.com/g/pdfnet-sdk/c/DzD5WBN-2pM/m/knSCuABrAgAJ

static public void DisableRectBorder(Annot annot, PDFDoc doc)
{
ElementReader reader = new ElementReader();
ElementWriter writer = new ElementWriter();
ElementBuilder builder = new ElementBuilder();

writer.Begin(doc); // start new content stream
Obj old_app_stm = annot.GetAppearance();
reader.Begin(old_app_stm);

Element element;
bool firstPath = true;

while ((element = reader.Next()) != null)
{
if(firstPath && element.GetType() == Element.Type.e_path)
{
firstPath = false;
element.SetPathStroke(false);
//element.SetPathFill(false); // optional
}
writer.WriteElement(element);
}
// not changing the size of the appearance so keep BBox value
Obj new_app_stm = writer.End();
new_app_stm.Put(“BBox”, old_app_stm.FindObj(“BBox”));

annot.SetAppearance(new_app_stm);
}