How to Customize Text, Font, Color & Size of Barcode Caption inside .NET Apps

This Technical tip explains how .NET developers can manage caption of the barcode inside their .NET applications using Aspose.BarCode for .NET. Sometimes, developers might be interested in displaying some extra information on the barcode image that is called Caption. Using Aspose.BarCode, developers can display captions on above, below or both positions of the barcode image. It is also possible to customize the text, alignment, font, color and space of the caption. Aspose.BarCode provides a Caption class to serve this purpose. All barcode generating classes have two properties, CaptionAbove and CaptionBelow that take an instance of Caption class. So, developers can create an object of Caption class and then assign that object to CaptionAbove, CaptionBelow or both properties to set the captions of the barcode.
//your code here...// Code sample for Managing Caption of the Barcode //[C# Code Sample] //Instantiate barcode object BarCodeBuilder bb = new BarCodeBuilder(); //Set the Code text for the barcode bb.CodeText = "1234567"; //Set the symbology type to Code128 bb.SymbologyType = Symbology.Code128; //Create caption object. Set its text and text alignment & also make it visible Caption caption = new Caption(); caption.Text = "Aspose.BarCode"; caption.TextAlign = System.Drawing.StringAlignment.Center; caption.Visible = true; //Assign caption object to be displayed above and below the barcode bb.CaptionAbove = caption; bb.CaptionBelow = caption; //Save the image to your system and set its image format to Jpeg bb.Save("barcode.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //[VB.NET Code Sample] 'Instantiate barcode object Dim bb As BarCodeBuilder = New BarCodeBuilder() 'Set the Code text for the barcode bb.CodeText = "1234567" 'Set the symbology type to Code128 bb.SymbologyType = Symbology.Code128 'Create caption object. Set its text and text alignment & also make it visible Dim caption As Caption = New Caption() caption.Text = "Aspose.BarCode" caption.TextAlign = System.Drawing.StringAlignment.Center caption.Visible = True 'Assign caption object to be displayed above and below the barcode bb.CaptionAbove = caption bb.CaptionBelow = caption 'Save the image to your system and set its image format to Jpeg bb.Save("barcode.jpg", System.Drawing.Imaging.ImageFormat.Jpeg) // Continuing the sample above, the following sample shows Font and Color setting //[C# Code Sample] bb.CaptionAbove.TextAlign = StringAlignment.Near; bb.CaptionAbove.Text = "Aspose.Demo"; bb.CaptionAbove.Visible = true; bb.CaptionAbove.Font = new System.Drawing.Font("Pristina", 14f); bb.CaptionAbove.ForeColor = Color.OrangeRed; bb.CaptionBelow.TextAlign = StringAlignment.Far; bb.CaptionBelow.Text = "Aspose.Demo"; bb.CaptionBelow.Visible = true; bb.CaptionBelow.Font = new System.Drawing.Font("Pristina", 14f); bb.CaptionBelow.ForeColor = Color.OrangeRed; //[VB.NET Code Sample] bb.CaptionAbove.TextAlign = StringAlignment.Near bb.CaptionAbove.Text = "Aspose.Demo" bb.CaptionAbove.Visible = True bb.CaptionAbove.Font = New System.Drawing.Font("Pristina", 14.0F) bb.CaptionAbove.ForeColor = Color.OrangeRed bb.CaptionBelow.TextAlign = StringAlignment.Far bb.CaptionBelow.Text = "Aspose.Demo" bb.CaptionBelow.Visible = True bb.CaptionBelow.Font = New System.Drawing.Font("Pristina", 14.0F) bb.CaptionBelow.ForeColor = Color.OrangeRed

Url: http://www.aspose.com/.net/barcode-component.aspx

Language: PHP | User: Sheraz Khan | Created: Jul 24, 2015 | Tags: Manage Caption of Barcode customize text of Barcode image customize Font of Barcode image Instantiate barcode object Set the Code text for the barcode Create caption object .NET Barcode API