Spire.Barcode is a professional barcode library specially designed for .NET developers (C#, VB.NET, ASP.NET, .NET Core) and Java developers (J2SE and J2EE) to generate, read and scan 1D & 2D barcodes.

Mon Mar 17, 2014 8:10 am

Hi,

Im using the code128. The size of the barcode always changes according to the input of the text. Can we fixed the width of the barcode even though the input is long?

Besides that, how do you change the height and width? My barcode labels are not as big as the demo shown.

Appreciate if you could reply.

Thank you.

Regards,
Cath

cath
 
Posts: 6
Joined: Thu Nov 21, 2013 4:15 am

Mon Mar 17, 2014 8:53 am

Hello,

Sorry. Spire.Barcode doesn’t support setting fixed width at present. To set the height of barcode, please refer to the following code:
Code: Select all
BarcodeSettings barsetting = new BarcodeSettings();
barsetting.X = 0.8f;
barsetting.Unit = GraphicsUnit.Millimeter;

//set the width of barcode
barsetting.BarHeight = 25;

barsetting.HasBorder = true;
barsetting.BorderWidth = 0.5F;

barsetting.Data = "545863";
barsetting.Data2D = "545863";
//generate EAN-Code 128
barsetting.Type = BarCodeType.EAN128;

BarCodeGenerator bargenerator = new BarCodeGenerator(barsetting);
Image barcodeimage = bargenerator.GenerateImage();
barcodeimage.Save("barcode.png");

System.Diagnostics.Process.Start("barcode.png");

If there are any questions, welcome to tell us.

Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Thu Apr 20, 2017 9:30 am

Hello,

Thanks for patience waiting.
Our Spire.Barcode has supported setting fixed width. Welcome to download new version(https://www.e-iceblue.com/Download/down ... r-net.html) and test the below code.
Code: Select all
barsetting.Unit = GraphicsUnit.Pixel;
barsetting.ImageWidth = 200f;
barsetting.AutoResize = false;


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Jul 24, 2019 6:39 am

Hi,
I use the minimum size of the barcode I created?
So, what are the settings for creating 5mm x 2mm barcode as an example?
Thanks

erkaneser1
 
Posts: 1
Joined: Tue Jan 30, 2018 6:26 am

Wed Jul 24, 2019 11:42 am

Hello Erkaneser1,

Thanks for your inquiry.
You can refer to the following code snippet. But please kindly note that the Barcode has a minimum width according to its data. When the minimum width exceeds the image width(5mm), the Barcode will be cropped. The 5mm is too narrow, I suggest that you increase the image width to test your case. If there is any question, welcome to write back.
Code: Select all
BarcodeSettings barsetting = new BarcodeSettings();
barsetting.ImageWidth = 5f;
barsetting.BarHeight = 2f;
.....


Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Tue Jul 30, 2019 3:42 am

Hello Erkaneser1,

Greetings from E-iceblue.
Did my code help you? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.BarCode

cron