tags:

views:

81

answers:

3

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?

+3  A: 

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.

Dolph
Right. The Print classes in WinForms are easy to use but use a scaling that makes it low-res.
Henk Holterman
For reference, the `Graphics` object is .net's way of representing a device context, rendering context, or whatever $PLATFORM decides to call it. You draw on a Graphics, and you hardly have to care whether it represents a window's client area, a printed page, or any other visual medium.
cHao
A: 

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.

Mau
A: 

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.

Mark Ingram