Hello! I'm attempting to use Pdf.Kit to add text with surrounding boxes. I'm using C#, PdfFileMend.AddText, and PdfContentEditor.CreatePolygon to do so; however I'm having trouble getting them to line up.
I created this elemental test to reproduce the issue with a simple "axis" and text, which I expected would rest in the upper-right quadrant of the axis. It does not, and I'm not sure why; I'm relatively new to PDF and brand new to Pdf.Kit. Please investigate for me.
I run through this code twice, once with PdfFileMend instance "pfm", and once with PdfContentEditor instance "pce":
Point tOrigin =
new Point(10, 10);
Rectangle tRect =
new Rectangle(tOrigin.X-10, tOrigin.Y-10, 20, 20);
if ( stage == "PdfContentEditor" )
{
LineInfo liTestPCE =
new LineInfo();
liTestPCE.LineColor = Color.FromArgb(255,0,0);
liTestPCE.VerticeCoordinate =
new float[12]
{
tOrigin.X-tRect.Width/2, tOrigin.Y,
tOrigin.X+tRect.Width/2, tOrigin.Y,
tOrigin.X, tOrigin.Y,
tOrigin.X, tOrigin.Y-tRect.Width/2,
tOrigin.X, tOrigin.Y+tRect.Width/2,
tOrigin.X, tOrigin.Y
};
pce.CreatePolygon(liTestPCE, pageIdx+1, tRect, "");
}
else if ( stage == "PdfFileMend" )
{
FormattedText ftText =
new FormattedText( "|____",
Color.FromArgb(0,0,255), Aspose.Pdf.Kit.FontStyle.Courier,
EncodingType.Winansi,
false, 9);
pfm.AddText( ftText, pageIdx+1, tOrigin.X, tOrigin.Y, tOrigin.X + tRect.Width, tOrigin.Y + tRect.Height );
}