Hi all,
I am attempting to create a WebLink that overlays drawn text. I am using the same XRect when drawing the text and adding the web link. An example of my current code is:
Code:
PdfDocument document = new PdfDocument();
PdfPage page = document.Pages.Add();
XFont font = new XFont("Arial Unicode MS", 10, XFontStyle.Regular);
string text = "Hello World";
XGraphics gfx = XGraphics.FromPdfPage(page);
XSize textSize = gfx.MeasureString(text, font);
XPoint textLocation = new XPoint(50, 50);
XRect textRectangle = new XRect(textLocation, textSize);
gfx.DrawString(text, font, XBrushes.Black, textRectangle, XStringFormats.TopLeft);
page.AddWebLink(new PdfRectangle(textRectangle), "http://www.google.com");
However, the above code creates the text in the top left corner and the annotation in the bottom left. In order to get the two elements to line up I need to invert the annotation's Y position like so:
Code:
XPoint invertedYPoint = new XPoint(textLocation.X, page.Height - textLocation.Y - textSize.Height);
page.AddWebLink(new PdfRectangle(invertedYPoint, textSize), "http://www.google.com");
Is this intended behavior, or perhaps there are orientation settings I need to add/change?
Thanks!