how to improve printed text quality after using "graphics.DrawString"?

Shima.Y picture Shima.Y · Jul 25, 2012 · Viewed 9.3k times · Source

I have a problem with my text quality after printing ! it's not smooth and antialiases!

This is the story :

I create a graphic from a bitmap (Graphics.FromImage(MyBitmap)) and I think it's the start point of my problem because I can't use PrintPageEvenArg(e) , but I have no other choice!

after that I begin writing some text on this graphic:

by reading the answers of similar Questions in this site and some others , I made some changes on my graphics properties such as smoothingMode , TextRenderingHint , ... that U see in continue... but unfortunately none of them helped me !

  SolidBrush sb = new SolidBrush(Color.White);
  graphics.FillRectangle(sb,oRectangle); //it was suggested to be done before antialiases inorder to get effects

  graphics.TextRenderingHint = TextRenderingHint.AntiAlias; //I also tried ClearTypeGridFit
  graphics.SmoothingMode = 
        System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
  graphics.CompositingQuality = CompositingQuality.HighQuality;
  graphics.CompositingMode = CompositingQuality.SourceOver;

  graphics.DrawString(strValue, boxStyle.Font, sb, oRectangle, StringFormat);

by antialising I got better smooth edge but I see a lot of extra pixel near my text and my text color seems to become lighter so I can say that by smoothing edge my text quality even got worse !

plz help me ! Thanx in advance :)

Answer

Yevgeniy picture Yevgeniy · Jul 25, 2012

Try to use this solution (GraphicsPath). In my project it works very good.