Tutorial :Achieving MS Word print quality in C#



Question:

I am writing a small application that prints some stickers to a special printer.

When I use MS Word to print some text to that printer (and to an XPS file), the result looks excellent. When I print from C# code with the Graphics object, the text appears to be over-pixelized or over-smoothed.

I tried the following hints, but none produced the same result as MS Word:

System.Drawing.Drawing2D.SmoothingMode.AntiAlias  System.Drawing.Text.TextRenderingHint.AntiAliasGridFit  System.Drawing.Text.TextRenderingHint.AntiAlias  System.Drawing.Text.TextRenderingHint.ClearTypeGridFit  InterpolationMode.NearestNeighbor  CompositingQuality.HighQuality  

And some others.

Can you advice which hints are applied by MS Word, so I could create it programatically?


Solution:1

I'm not familiar with the Graphics object, but I'm guessing you're sending a bitmap to the printer instead of text or vector graphics.

If so, increase the resolution/DPI of the image you're creating to approach that of the printer, or switch to a rich text (XPS) or vector-based format.


Solution:2

Windows GDI (on which Graphics is based) is a raster technology. You are generating (possibly low-res) bitmaps.

Options include: instantiate a larger graphics object and print bigger text (== increasing resolution of the print), or move to WPF, which has a vector model and lets you generate XPS files natively.


Solution:3

You'll need to be printing at least 300DPI for it to look any good. 600DPI would be better. You're probably printing at something around 96DPI by just drawing straight out to the printer.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »