private void DrawStringAtPosition(Graphics pGraphics, string pText, int Top, DrawStringPosition pPosition) { var HeaderTextSize = new SizeF(pGraphics.MeasureString(pText, CurrentFont)); var HeaderTextWidth = HeaderTextSize.Width; var PageWidth = PageSettings.Bounds.Right - PageSettings.Bounds.Left; float Left; if (pPosition == DrawStringPosition.Left) { Left = PageSettings.Margins.Left; } else if (pPosition == DrawStringPosition.Center) { Left = ((PageWidth - HeaderTextWidth) / 2); } else if (pPosition == DrawStringPosition.Right) { Left = PageWidth - PageSettings.Margins.Right - HeaderTextWidth; } else { throw new Exception(); } pGraphics.DrawString(pText, CurrentFont, Brushes.Black, Left, Top); }