Blurry text when generating and printing an ID card

最后都变了- 提交于 2019-12-12 17:54:12

问题


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:

  1. Grab the image "frame".
  2. Grab the employee's photograph.
  3. Merge them.
  4. Create a new bitmap from the generated image.
  5. Add two sets of text on top of the bitmap (FontBrush color set to Black).
  6. 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.CompositingQuality = 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;
    }

回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/5564433/blurry-text-when-generating-and-printing-an-id-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!