Graphics.DrawString center in printdocument width
I'm attempting to center a string on a printdocument. I've done the following with an image and it works but doesn't seem to work the same with a string. Here is the code that I used to center the image e.Graphics.DrawImage(logo, (e.MarginBounds.Width / 2) - (logo.Width / 2), height); The text i'm trying to center is being supply from a Tab in a TabControl using (var sf = new StringFormat()) { height = logo.Height + 15; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; e.Graphics.DrawString(tabData.Text, new Font(this.Font.Name, 10), new SolidBrush(tabData