首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从ASP.NET中的BarCode下方删除文本(C#)

从ASP.NET中的BarCode下方删除文本(C#)
EN

Stack Overflow用户
提问于 2010-02-11 20:00:08
回答 3查看 5.9K关注 0票数 4

我正在生成条形码,条形码生成工作很好,条形码也读出来了,perfectly.followin是条形码生成的代码:

代码语言:javascript
复制
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();
}

alt text http://www.freeimagehosting.net/uploads/0e033f305b.png

现在,我想删除条形码下面的文本。我该怎么做呢?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2010-02-11 20:54:26

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

尝试如下所示:Free Barcode Font - Code 39

票数 6
EN

Stack Overflow用户

发布于 2011-09-06 18:33:50

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

代码语言:javascript
复制
Barcode128 code128 = new Barcode128();
code128.CodeType = Barcode.CODE128;
code128.Code = "123456789";
code128.Font = null;
票数 10
EN

Stack Overflow用户

发布于 2010-02-11 20:36:13

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2244225

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档