| |
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);
var 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));
var 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("annotations2.pdf");
}

|
|
|