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.
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.
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.
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.
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.
Can you please share the sample code for drawing a cloud annotation ? It would be really helpeful for others.
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);