Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Documents.Reports.GraphicsProxy DrawString for multi-line strings increments y position of each line by measured height of entire multi-line string instead of a single line height

The GraphicsProxy adds too much space between each line for multi-line strings. I'm using version 17.2.20172.2006. 

Passing in string "a\r\nb" ends up looking like "a\r\n\r\nb" (Shown in PDF). The method in question is below. Any ideas?


		public void DrawString(string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, System.Drawing.StringFormat format)
			if (s == null) throw new ArgumentNullException("s");
			if (font == null) throw new ArgumentNullException("font");
			if (brush == null) throw new ArgumentNullException("brush");

			_graphics.Font = GetFont(font);
			_graphics.Brush = GetBrush(brush);

			float h = _memoryGraphics.MeasureString(s, font).Height;

			CharBuffer cb = new CharBuffer();

			foreach (char ch in s)
				if (ch == '\r') continue;

				if (ch == '\n')
					if (cb.Count > 0)
						_graphics.DrawString(x, y, cb.ToString());

					y += h;

			if (cb.Count > 0) _graphics.DrawString(x, y, cb.ToString());

Parents Reply Children
No Data