English 中文(简体)
从ASP.NET(C#)的条形码下方删除文本。
原标题:Remove Text from below of the BarCode in ASP.NET(C#)

我正在生成条形码,条形码生成正常,条形码也可以被很好地读取。以下是产生条形码的代码:

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 无法翻译此段文字,因为它是一个HTML标记,而不是单独的文本。它通常用作添加图像的链接。

Now I want to remove the text which is below of the barcode. how can I do this?.

最佳回答

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

试试这个:免费条码字体 - Code 39

问题回答

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

Barcode128 code128 = new Barcode128();
code128.CodeType = Barcode.CODE128;
code128.Code = "123456789";
code128.Font = null;

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

唯一的方法是在呈现文本后修改位图(或裁剪它)才能将它们删除;这需要知道最终条形码的大小。虽然不是不可能,但却很麻烦。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签