Using below code I'm producing a barcode image used for a label - however the size of the image changes with different values
I need to make a fixed size image, how??
Say, using values an image of these size's a returned:
Value="1234567891234000090" : W=1106px, H=203px
Value="123-123-123-1000090" : W=984px, H=197px
String barcodeValue = @"123-123-123-1";
BarcodeWriter barcodeWriter = new BarcodeWriter();
You say that only value string length is dependant on sizes on resulting barcode image!
Why is the two samples in previous post of different sizes (they have same value length)??
The value of my barcodes will always be exactly 21 chars - but when using hyphens, blanks or possibly other spec. chars the size is changed on resulting image...??
The barcode width depends on codewords count which is utilized to encode your string value (more info you can find in official Code 128 barcode specification).
Here are the codewords for your values:
Hereby the second generated barcode image will be 11*8 (88) single bars longer than the first one.
So to inscribe the barcode Nr2 in specified, by SetWidth and SetHeight properties, rectangle its single bar width will be automatically taken
a bit less than for the barcode Nr1. So it is evident that the resulting width in pixels for your barcodes won't concur exactly.
To get these barcode images generated of the same size you should either stretch them up as described above or
draw the lesser image in center of required rectangle (white background preferable).