Re: Generated barcodes too wide
Posted: Fri Jan 20, 2017 8:05 pm
OK, thank you for your help.
Here you can ask questions and get answers about VintaSoft products.
http://www.vintasoft.com/forums/
Code: Select all
public static System.Drawing.Image GetBarcode128WithDimension(ParcelLabelOrientation parcelLabelOrientation, string textForBarcode, int resolution, float barcodeDimension, int codeWidth, int codeHeight)
{
ImageFormat imageformat = ImageFormat.Png;
int width = (int)((codeWidth / 10) / 2.54 * 72);
int height = (int)((codeHeight / 10) / 2.54 * 72);
Image image = null;
BarcodeWriter writer = new BarcodeWriter();
writer.Settings.SetHeight(height - writer.Settings.ValueFont.Height * 2, UnitOfMeasure.Pixels);
writer.Settings.Barcode = BarcodeType.Code128;
writer.Settings.Value = textForBarcode;
using (GraphicsPath barcodePath = writer.GetBarcodeAsGraphicsPath())
{
image = new Bitmap(width, height, PixelFormat.Format24bppRgb);
using (Graphics g = Graphics.FromImage(image))
{
// draw barcode path
RectangleF barcodePathBounds = barcodePath.GetBounds();
g.Clear(Color.White);
float padding = 5;
using (Matrix m = new Matrix((width - padding * 2) / barcodePathBounds.Width, 0, 0, 1, padding, padding))
barcodePath.Transform(m);
// enable AntiAlias if need!
//g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillPath(Brushes.Black, barcodePath);
}
return image;
}
Please send your image with the problem description to support@vintasoft.com.I'd like to send you a sample of barcode I created (in PNG or PDF format) but I don't see a way to send the sample document to you. How can I do it ?