Moshe
Moshe

Reputation: 2668

Achieving MS Word print quality in C#

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?

Upvotes: 5

Views: 681

Answers (3)

Dolph
Dolph

Reputation: 50660

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.

Upvotes: 3

Mark Ingram
Mark Ingram

Reputation: 73635

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.

Upvotes: 0

Mau
Mau

Reputation: 14468

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.

Upvotes: 0

Related Questions