How to create a cloud (polygon) annotation

160 views
Skip to first unread message

Michael

unread,
Jan 12, 2015, 3:42:01 PM1/12/15
to pdfne...@googlegroups.com
I would like to be able to programatically add a rectangular cloud annotation to an existing PDF document. I have successfully created a Polygon and used SetVertex() to set the vertices. I have also used Polygon.SetBorderEffect(Markup.BorderEffect.e_Cloudy), Polygon.SetBorderEffectIntensity(intensity), and Polygon.SetIntentName(PolyLine.IntentType.e_PolygonCloud). However, I can't get it to look like a cloud. It looks like a rectangle.

I also experimented with adding my own border effect dictionary using the SDFObj. I can get a cloud-looking annotation this way, but if I call RefreshAppearance() or Flatten(), the "cloudiness" is lost.

Perhaps someone could post an example of creating a cloud polygon annotation correctly? Thanks in advance.

Ryan

unread,
Jan 12, 2015, 6:23:48 PM1/12/15
to pdfne...@googlegroups.com
Hi Michael, sorry but we don't currently support rendering the "cloud" border effect, however we will be adding this in a future version of the library, and the more feedback we get on a feature/improvement the sooner it will be added.

However it sounds like you are already there with your own custom appearance. Calling RefreshAppearance will erase the current one, and generate a new appearance, which doesn't consider the cloud effect, so avoid calling that method.

If you just call Flatten, without calling RefreshAppearance, then your cloudy appearance should be the flattened one.

Thank you for your feedback.

Michael

unread,
Jan 13, 2015, 9:05:32 AM1/13/15
to pdfne...@googlegroups.com
Thanks, Ryan.  If you could clarify one thing... how will the flattened annotation appear if I call Flatten without calling RefreshAppearance?  It does not seem to have the cloud border effect for me once flattened.  Thanks.

Ryan

unread,
Jan 13, 2015, 2:12:06 PM1/13/15
to pdfne...@googlegroups.com
Flatten will check for a pre-existing appearance for the normal appearance mode. It would only call RefreshAppearance if there isn't one.

So the only thing I can think of is you are not setting your appearance for the normal appearance mode? That is, annotations can have alternate appearances, such as mouse over.

If you call Annot.SetAppearance(strm_obj); then this would be the normal setting.
http://www.pdftron.com/pdfnet/docs/PDFNet/?topic=html/Overload_pdftron_PDF_Annot_SetAppearance.htm

If you are still stuck, can you reproduce by modifying the AnnotationTest sample that came with the SDK you are using. If so send it to support along with what OS you are using.

Mohan Babu Malairaj

unread,
Aug 19, 2015, 1:32:49 PM8/19/15
to PDFTron PDFNet SDK
Hi Michael,
Can you please share the sample code for drawing a cloud annotation ? It would be really helpeful for others.

Ryan

unread,
Jan 14, 2020, 3:44:11 PM1/14/20
to PDFTron PDFNet SDK
Support for Cloudy annotations was added a while ago, so updating this forum post in case others are looking for this.

The following C# code shows how to create a Cloudy Polygon annotation.

pdftron.PDF.Annots.Polygon polygon = pdftron.PDF.Annots.Polygon.Create(doc, new Rect(117, 544, 370, 737));
polygon
.SetVertex(0, new Point(127, 648));
polygon
.SetVertex(1, new Point(191, 727));
polygon
.SetVertex(2, new Point(345, 714));
polygon
.SetVertex(3, new Point(361, 553));
polygon
.SetVertex(4, new Point(154, 553));
polygon
.SetBorderStyle(new Annot.BorderStyle(Annot.BorderStyle.Style.e_solid, 2));
polygon
.SetBorderEffect(Markup.BorderEffect.e_Cloudy);
polygon
.SetIntentName(PolyLine.IntentType.e_PolygonCloud);
polygon
.SetColor(new ColorPt(1, 0, 1));
polygon
.RefreshAppearance();
page
.AnnotPushBack(polygon);


Reply all
Reply to author
Forward
0 new messages