// Convert rectangle from world space to page space. This is necessary because the annotation is
// placed relative to the bottom left corner of the page with units measured in point.
XRect rect = gfx.Transformer.WorldToDefaultPage(new XRect(30, 30, 30, 30));
textAnnot.Rectangle = new PdfRectangle(rect);
PdfPage page = document.AddPage(); PdfTextAnnotation textAnnot = new PdfTextAnnotation { Title = "标题乱码", Subject = "22222", Contents = "11111.\r11111.123", Opacity = 0.5, Open = true, Icon = PdfTextAnnotationIcon.NoIcon,
};
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("KaiTi", 14, XFontStyle.Bold);
gfx.DrawString("这是我要写的一句话", font, XBrushes.Black, 30, 50, XStringFormats.BottomLeft);
// Convert rectangle from world space to page space. This is necessary because the annotation is // placed relative to the bottom left corner of the page with units measured in point. XRect rect = gfx.Transformer.WorldToDefaultPage(new XRect(30, 30, 30, 30)); textAnnot.Rectangle = new PdfRectangle(rect);
page.Annotations.Add(textAnnot);