When you change the size of the 1d barcode in AutoResize mode (
AutoResize is true), the barcode text area will automatically be resized.
If you need manually adjust the barcode text area settings, such as margin space between text and barcode, text font family or size. You can try the following C# code.
- Create a barcode with specified width and height using AutoResize mode.
- Set property AutoResizeBarcodeText to false. Now you can manually apply the barcode text size related options.
- Set TextMargin to the space between barcode and text
- Set TextFont with your target text font family and size
Linear barcode = new Linear();
barcode.Type = BarcodeType.CODE128;
barcode.Data = "Code 128 - 1234567890";
barcode.AutoResize = true;
barcode.UOM = UnitOfMeasure.INCH;
barcode.Resolution = 900; // 900 dot (pixel) per inch
barcode.BarcodeWidth = 1; // 1 inch
barcode.BarcodeHeight = 0.6f;
barcode.AutoResizeBarcodeText = false;
barcode.TextMargin = 0.0333f;
barcode.TextFont = new Font("OCR-B", 20);
barcode.drawBarcode("C://Output//OnBarcode.com//csharp-barcode-size-code128-text.png");
We have listed the complete barcode size customization properties. You can view details here:
List of barcode size customization properties in barcode library