Remove bottom text of BarCode in ASP.NET (C #)

I generate a barcode, creating a barcode, a thin barcode works, also read it perfectly. As a code to generate a barcode:

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

Now I want to remove text that is below the barcode. How can i do this?

+4
source share
3 answers

A better alternative might simply be to use a font that has no text in the first place:

Try something like: Free Barcode Font - Code 39

+6
source

You can set Font = null; to remove text under the barcode.

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

You create a barcode using a font, and charcters under the columns are part of this font.

The only way to remove them is to change the bitmap (or crop it) after rendering the text; which requires knowing how big the last barcode is. Impossible to do, but pain.

+1
source

Source: https://habr.com/ru/post/1300988/


All Articles