Free Support Forum -

Displaying the Caption on the top left a little far from the bars below

I am trying to place the barcode Caption text at the top of the barcode image which does get displayed but the issue is the caption at the top is not displaying the text in a single line in a readable font size.

Below is the code snippet:-
Caption captionAbove = new Caption
Text = string.Format("{0}-{1}-{2}-{3}-{4}-{5}", “ISBN”, barCodeValue.Substring(0,3), barCodeValue.Substring(3, 1), barCodeValue.Substring(4,7),
barCodeValue.Substring(11, 1), barCodeValue.Substring(12, 1)),
TextAlign = StringAlignment.Far,
Visible = true,
Font = new System.Drawing.Font(“Arial”, 6f),
ForeColor = System.Drawing.Color.Black,
Space = 1f

        var barColor = System.Drawing.Color.FromArgb(0, 0, 0);
        using (var bb = new BarCodeBuilder(barCodeValue))
            bb.AutoSize = true;
            bb.GraphicsUnit = GraphicsUnit.Millimeter;
            bb.CodeTextColor = barColor;
            bb.BarHeight = 40f;
            bb.xDimension = 0.30f;
            bb.Margins = new MarginsF(1.5f, 1.5f, 1f, 0.5f);
            bb.CaptionAbove = captionAbove;
            bb.CodeLocation = CodeLocation.None;
            var curResolution = new Resolution(300f, 300f, ResolutionMode.Graphics);
            var curFont = new System.Drawing.Font("Arial", 9f);
            bb.ImageQuality = ImageQualityMode.AntiAlias;
            bb.Resolution = curResolution;
            bb.CodeTextFont = curFont;
            bb.SymbologyType = Symbology.EAN13;
            bb.RotationAngleF = SetRotation(rotation);

            tempBarCodeImageFile = Path.Combine(TempFolderRoot, (Guid.NewGuid() + ".jpg"));
            bb.Save(tempBarCodeImageFile, System.Drawing.Imaging.ImageFormat.Jpeg);

Here is the requirement [Image at the top is how the caption should be displayed]
image.jpg (7.5 KB)

Please let me know if there is any setting(s) to change to get the desired result.


Thank you for your inquiry along with the details and sample. We are able to generate the ISBN barcode using the following code snippet. Sample output is attached for your reference. You may modify your code and adjust the snippet accordingly.


        using (Aspose.BarCode.BarCodeBuilder builder = new Aspose.BarCode.BarCodeBuilder("9780123465788", Aspose.BarCode.Generation.EncodeTypes.ISBN))
            builder.CaptionAbove.Visible = true;
            builder.GraphicsUnit = GraphicsUnit.Pixel;

            builder.CaptionAbove.Font = new Font("Arial", 6);
            builder.CodeTextFont = new Font("Arial", 6);
            builder.CaptionAbove.Text = "ISBN-978-0-1234657-8-8";
            builder.xDimension = 1f;
            builder.BarHeight = 40f;


isbn_bar_test.jpg (2.4 KB)

Hope the above information helps. Feel free to contact us in case of any query or comments.

Thanks for looking into it but the issue here is i am using Aspose.Barcode version 3.0 and the above provided code is of version, I don’t have Aspose.BarCode.Generation.EncodeTypes.ISBN in here so if you could provide me a solution for 3.0 version , that would be a great help.

Also i tried using barcode code text you had given , it doesn’t show me the caption . may be i miss on license , i had installed via Package manager console so isn’t that has to be taken care automatically.
Below is the image -
image.jpg (5.8 KB)

Please let me know if there is a way to make a caption bigger but still on single line and positioned a little far from the bar for version 3.0


You are using very old version of Aspose.BarCode. It is always recommended to use the latest version of the API as it includes new features and bug fixes reported by other customers. Please update your license and try again. In case you face any issue, feel free to contact us. You can tested it by using the temporary license for 30 days. Get a temporary license, use it and share the feedback.