3

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 :)

Shima.Y
  • 373
  • 4
  • 9
  • 18
  • 1
    ClearType and the other text rendering hints you're trying to apply are intended for **on screen** images. They don't do anything at all when printing. And that's pretty much how anti-aliasing works. It adds extra pixels in varying colors or shades of gray that help to smooth out the edges of text. It's not really clear what's causing your problem; printers are extremely high resolution, so they should be capable of outputting high quality images. Why can't you use `PrintPageEventArgs`? Why do you "have no other choice?" – Cody Gray - on strike Jul 25 '12 at 08:18
  • @CodyGray:because I'm working on a project that had written before , and the solution has threads and many methods that I can't completely change them . and all the methods such as MyPrintDocument_PrintPage that has this event , calls after the time that I need this event! – Shima.Y Jul 26 '12 at 17:47

1 Answers1

3

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

Yevgeniy
  • 84
  • 2
  • thanx , I'll try it and tell U how was the result :) – Shima.Y Jul 26 '12 at 20:16
  • I used GraphicsPath , it had a good effect on antialiasing but unfortunately I have an extra prob of saving and restoring image before printing , so I get a low quality that covered the profits of your solution , can U see my new Question in this link and help me if you can ? http://stackoverflow.com/questions/11699219/save-an-image-as-a-bitmap-without-loosing-quality – Shima.Y Jul 28 '12 at 07:43