4

我正在生成条码的条码生成工作正常条码也可以完美读取。以下是条码生成的代码:

private void GenerateBarCode(string codeInfo)
{
    //Settings for the Image
    string TypeFaceName = "IDAutomationHC39M";
    string imageLocation = Server.MapPath("2010.png");
    //The format of the image file
    ImageFormat format = ImageFormat.Png;
    //path of unique file name    
    string path = "D://MyProjects//RepeaterPaging//images//vijendra.png";
    //REFERENCING A FONT 
    PrivateFontCollection fnts = new PrivateFontCollection();
    fnts.AddFontFile("IDAutomationHC39M.ttf");
    FontFamily fntfam = new FontFamily(TypeFaceName);
    Font fnt = new Font(fntfam, 13);
    fnts.AddFontFile("Arial.ttf");
    FontFamily fntfam2 = new FontFamily("Arial", fnts);
    //DRAWING THE IMAGE  
    Bitmap bmp = new Bitmap(960, 386);           //Canvas size
    Graphics g = Graphics.FromImage(bmp);
    Bitmap orignBitmap = new Bitmap(imageLocation);
    g.Clear(Color.Transparent); //Background color
    SizeF bc = g.MeasureString(codeInfo, fnt);
    Brush br = new SolidBrush(Color.Black);
    g.DrawImage(orignBitmap, 10, 8);
    g.DrawString(codeInfo, fnt, br, 585, 170); //Drawing the Image
    g.TextRenderingHint= 
    bmp.Save(path, format); //Saving the Image file
    bmp.Dispose(); //Releasing all resources (Image file) 
    Response.Clear();
}

替代文字 http://www.freeimagehosting.net/uploads/0e033f305b.png

现在我想删除条形码下方的文本。我怎样才能做到这一点?。

4

3 回答 3

10

您可以设置Font = null;删除条形码下方的文本。

Barcode128 code128 = new Barcode128();
code128.CodeType = Barcode.CODE128;
code128.Code = "123456789";
code128.Font = null;
于 2011-09-06T10:33:50.443 回答
6

一个更好的选择可能是只使用首先没有文本的字体:

尝试类似: 免费条形码字体 - 代码 39

于 2010-02-11T12:54:25.700 回答
1

您正在使用字体创建条形码,并且条形下方的字符是该字体的一部分。

删除它们的唯一方法是在渲染文本后修改位图(或裁剪它);这需要知道最终的条形码有多大。不是做不到,而是很痛苦。

于 2010-02-11T12:36:13.140 回答