Blurry text when generating and printing an ID card
I am generating ID cards via .NET and I am having a problem where the dynamic text I insert appears so blurry that I have to use a bold font for it to be begrudgingly accepted.
What I'm currently doing:
- Grab the image "frame".
- Grab the employee's photograph.
- Merge them.
- Create a new bitmap from the generated image.
- Add two sets of text on top of the bitmap (FontBrush color set to Black).
- Save the image in
PNG
and with the highest quality I can get.
Is there something to be done when generating the image to improve the printing on PVC ID cards?
public TextOnImage AddText(string message, Font font, PointF point)
{
using (Graphics g = Graphics.FromImage(Image))
{
g.Com开发者_运维问答positingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
//g.TextContrast = 0;
//g.TextRenderingHint = TextRenderingHint.AntiAlias; <-- Still didn't work
g.DrawString(message, font, Brush, point, StringFormat);
}
return this;
}
Assuming you are using GDI+, try turning off Anti-Aliasing by setting the TextRenderingHint on the graphics object to another value: http://msdn.microsoft.com/en-us/library/ssazt6bs.aspx
Although this helped, I ended up generating a PDF so the printer would read the font directly. This way, the printer doesn't try to "paint" the font's edges, and simply prints the text in an optimized way.
More information: Overlay text over an image background and convert to PDF
精彩评论