I am using Vintasoft barcode writer to create barcode images that I am inserting into a PDF document creatéd with iTextSharp.
I want to create a Barcode128 image with a specific Dimension (XFactor) ( XFactor = 0.375 millimeters) but the resulting barcode is always wider (almost 2 x the expected size) than what I expected, so the barcode does not fit in the document I created.
The value to store in the barcode is given by our client, so it is supposed to fit the barcode width specified (50 mm).
Can you help me ? Is there any error in the configuration I use ?
Thank you.
The code I use is the following :
Code: Select all
resolution = 72
textForBarcode = "8R27854156264";
width = 50; // in millimeters
height = 25; // in millimeters
public static Bitmap GetBarcode128(ParcelLabelOrientation parcelLabelOrientation, string textForBarcode, int resolution, int width, int height)
{
if (String.IsNullOrEmpty(textForBarcode))
{
return null;
}
Bitmap img = null;
// set barcode writer settings
BarcodeWriter barcodeWriter = new BarcodeWriter();
barcodeWriter.Settings.Resolution = resolution;
barcodeWriter.Settings.Barcode = BarcodeType.Code128;
barcodeWriter.Settings.SetHeight(height, UnitOfMeasure.Millimeters);
barcodeWriter.Settings.SetMinWidth(0.375, UnitOfMeasure.Millimeters);
barcodeWriter.Settings.Code128EncodingMode = Vintasoft.Barcode.BarcodeInfo.Code128EncodingMode.Undefined;
barcodeWriter.Settings.ValueVisible = false;
barcodeWriter.Settings.Value = textForBarcode;
// get a barcode image
img = barcodeWriter.GetBarcodeAsBitmap();
return img;
}