Our code here is
- Code: Select all
var pdfPage = pdfDocument.Pages.Add(
new dotnetDrawing::SizeF(_pageWidthBlockSizes, _pageHeightBlockSizes),
new PdfMargins() { Top = 0f, Right = 0f, Bottom = 0f, Left = 0f, All = 0f },
PdfPageRotateAngle.RotateAngle0,
PdfPageOrientation.Portrait
);
var pdfGraphicsState = pdfPage.Canvas.Save();
var pdfSolidBrush = new PdfSolidBrush(dotnetDrawing::Color.Black);
var pdfPen = new PdfPen(dotnetDrawing::Color.Black);
foreach (var item in impactFormItems)
{
var formattedValue = GetFormattedValue(item.Value, item.Type);
formattedValue = ImpactTruncateText(formattedValue, item);
var rectangleField = new dotnetDrawing::RectangleF(
new dotnetDrawing::PointF(item.CoordinateXPt, item.CoordinateYPt),
new dotnetDrawing::SizeF((item.Width * _xPointBlockSize), 10f)
);
pdfPage.Canvas.DrawString(
formattedValue,
new PdfFont(
(_pdfFontFamily == PdfDocumentFontFamily.Helvetica ? PdfFontFamily.Helvetica : PdfFontFamily.Courier), // e-IceBlue Spire PDF.NET doesn't have "Courier New" font family.
item.FontSize,
PdfFontStyle.Regular
),
pdfPen,
pdfSolidBrush,
rectangleField,
PdfTextAlignment.Left,
false
);
}
pdfPage.Canvas.Restore(pdfPage.Canvas.Save());