代码之家  ›  专栏  ›  技术社区  ›  Vijjendra

删除ASP.NET中条码下方的文本(C)

  •  4
  • Vijjendra  · 技术社区  · 16 年前

    我正在生成条码生成,条码运行良好,条码读取也很好,下面是条码生成的代码:

    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

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

    3 回复  |  直到 10 年前
        1
  •  6
  •   Nick Craver    16 年前

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

    尝试以下方法: Free Barcode Font - Code 39

        2
  •  9
  •   Kalu Singh Rao    10 年前

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

    Barcode128 code128 = new Barcode128();
    code128.CodeType = Barcode.CODE128;
    code128.Code = "123456789";
    code128.Font = null;
    
        3
  •  1
  •   Tony    16 年前

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

    删除它们的唯一方法是在呈现文本后修改位图(或对其进行裁剪);这需要知道最终条形码有多大。不是不可能的,而是痛苦。

    推荐文章