You may wish to generate a PDF document with markup created
dynamically at run-time.
The code below creates a set of markup Annotations including
squares, lines, text effects, circles and polygons.
using (var doc = new Doc()) {
//Markup annotations
doc.Page = doc.AddPage();
doc.Pos.X = 40;
doc.Pos.Y = doc.MediaBox.Top - 40;
doc.AddText("Markup annotations");
var cat = doc.ObjectSoup.Catalog;
var square = new SquareAnnotation(doc, new XRect("40 560 300 670"), XColor.FromRgb(255, 0, 0), XColor.FromRgb(0, 0, 255));
square.SquareElement.EntryBS = new BorderStyleElement(square.SquareElement);
square.SquareElement.EntryBS.EntryW = 8;
var line = new LineAnnotation(doc, new XPoint("100 565"), new XPoint("220 665"), XColor.FromRgb(255, 0, 0));
line.LineElement.EntryBS = new BorderStyleElement(line.LineElement);
line.LineElement.EntryBS.EntryW = 12;
line.RichTextCaption = "<span style= \"font-size:36pt; color:#FF0000\">Line</span>";
doc.FontSize = 24;
int fontID = doc.AddFont("Times-Roman", LanguageType.Latin);
doc.Pos.String = "400 670";
int id = doc.AddText("Underline");
var markup = new TextMarkupAnnotation(doc, fontID, TextMarkupType.Underline, XColor.FromRgb(0, 255, 0));
doc.Pos.String = "400 640";
fontID = doc.AddText("Highlight");
markup = new TextMarkupAnnotation(doc, fontID, TextMarkupType.Highlight, XColor.FromRgb(255, 255, 0));
doc.Pos.String = "400 610";
fontID = doc.AddText("StrikeOut");
markup = new TextMarkupAnnotation(doc, fontID, TextMarkupType.StrikeOut, XColor.FromRgb(255, 0, 0));
doc.Pos.String = "400 580";
fontID = doc.AddText("Squiggly");
markup = new TextMarkupAnnotation(doc, fontID, TextMarkupType.Squiggly, XColor.FromRgb(0, 0, 255));
var circle = new CircleAnnotation(doc, new XRect("80 320 285 525"), XColor.FromRgb(255, 255, 0), XColor.FromRgb(255, 128, 0));
circle.CircleElement.EntryBS = new BorderStyleElement(circle.CircleElement);
circle.CircleElement.EntryBS.EntryW = 20;
circle.CircleElement.EntryBS.EntryS = "D"; // dashed
circle.CircleElement.EntryBS.EntryD = new ArrayElement<Element>(Atom.FromString("[3 2]"), cat);
var arrowLine = new LineAnnotation(doc, new XPoint("385 330"), new XPoint("540 520"), XColor.FromRgb(255, 0, 0));
arrowLine.LineEndingsStyle = "ClosedArrow ClosedArrow";
arrowLine.LineElement.EntryBS = new BorderStyleElement(arrowLine.LineElement);
arrowLine.LineElement.EntryBS.EntryW = 6;
arrowLine.FillColor = XColor.FromRgb(255, 0, 0);
double[] v1 = new double[] { 100, 70, 50, 120, 50, 220, 100, 270, 200, 270, 250, 220, 250, 120, 200, 70 };
var polygon = new PolygonAnnotation(doc, v1, XColor.FromRgb(255, 0, 0), XColor.FromRgb(0, 255, 0));
double[] v2 = new double[] { 400, 70, 350, 120, 350, 220, 400, 270, 500, 270, 550, 220, 550, 120, 500, 70 };
var cloudyPolygon = new PolygonAnnotation(doc, v2, XColor.FromRgb(255, 0, 0), XColor.FromRgb(64, 85, 255));
cloudyPolygon.CloudyEffect = 1;
doc.Save(Server.MapPath("annotations2.pdf"));
}
Using doc As New Doc()
'Markup annotations
doc.Page = doc.AddPage()
doc.Pos.X = 40
doc.Pos.Y = doc.MediaBox.Top - 40
doc.AddText("Markup annotations")
Dim cat As Catalog = doc.ObjectSoup.Catalog
Dim square As New SquareAnnotation(doc, New XRect("40 560 300 670"), XColor.FromRgb(255, 0, 0), XColor.FromRgb(0, 0, 255))
square.SquareElement.EntryBS = New BorderStyleElement(square.SquareElement)
square.SquareElement.EntryBS.EntryW = 8
Dim line As New LineAnnotation(doc, New XPoint("100 565"), New XPoint("220 665"), XColor.FromRgb(255, 0, 0))
line.LineElement.EntryBS = New BorderStyleElement(line.LineElement)
line.LineElement.EntryBS.EntryW = 12
line.RichTextCaption = "<span style= ""font-size:36pt; color:#FF0000"">Line</span>"
doc.FontSize = 24
Dim fontID As Integer = doc.AddFont("Times-Roman", LanguageType.Latin)
doc.Pos.String = "400 670"
Dim id As Integer = doc.AddText("Underline")
Dim markup As New TextMarkupAnnotation(doc, fontID, TextMarkupType.Underline, XColor.FromRgb(0, 255, 0))
doc.Pos.String = "400 640"
fontID = doc.AddText("Highlight")
markup = New TextMarkupAnnotation(doc, fontID, TextMarkupType.Highlight, XColor.FromRgb(255, 255, 0))
doc.Pos.String = "400 610"
fontID = doc.AddText("StrikeOut")
markup = New TextMarkupAnnotation(doc, fontID, TextMarkupType.StrikeOut, XColor.FromRgb(255, 0, 0))
doc.Pos.String = "400 580"
fontID = doc.AddText("Squiggly")
markup = New TextMarkupAnnotation(doc, fontID, TextMarkupType.Squiggly, XColor.FromRgb(0, 0, 255))
Dim circle As New CircleAnnotation(doc, New XRect("80 320 285 525"), XColor.FromRgb(255, 255, 0), XColor.FromRgb(255, 128, 0))
circle.CircleElement.EntryBS = New BorderStyleElement(circle.CircleElement)
circle.CircleElement.EntryBS.EntryW = 20
circle.CircleElement.EntryBS.EntryS = "D"
' dashed
circle.CircleElement.EntryBS.EntryD = New ArrayElement(Of Element)(Atom.FromString("[3 2]"), cat)
Dim arrowLine As New LineAnnotation(doc, New XPoint("385 330"), New XPoint("540 520"), XColor.FromRgb(255, 0, 0))
arrowLine.LineEndingsStyle = "ClosedArrow ClosedArrow"
arrowLine.LineElement.EntryBS = New BorderStyleElement(arrowLine.LineElement)
arrowLine.LineElement.EntryBS.EntryW = 6
arrowLine.FillColor = XColor.FromRgb(255, 0, 0)
Dim v1 As Double() = New Double() {100, 70, 50, 120, 50, 220, _
100, 270, 200, 270, 250, 220, _
250, 120, 200, 70}
Dim polygon As New PolygonAnnotation(doc, v1, XColor.FromRgb(255, 0, 0), XColor.FromRgb(0, 255, 0))
Dim v2 As Double() = New Double() {400, 70, 350, 120, 350, 220, _
400, 270, 500, 270, 550, 220, _
550, 120, 500, 70}
Dim cloudyPolygon As New PolygonAnnotation(doc, v2, XColor.FromRgb(255, 0, 0), XColor.FromRgb(64, 85, 255))
cloudyPolygon.CloudyEffect = 1
doc.Save(Server.MapPath("annotations2.pdf"))
End Using