Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

Problem with BarCodeImage size

Last post 09-03-2010, 2:39 PM by saqib.razzaq. 1 replies.
Sort Posts: Previous Next
  •  09-02-2010, 9:50 AM 256837

    Problem with BarCodeImage size .NET

    Hello, I have problem. I want make barcode image with size 40mm x 18mm, but real size 35mm x 14mm.

    //e.Graphics.DpiX = 600

    //e.Graphics.DpiY = 600

    //width=40

    //height=18

    private void PrintOnPrinter(PrintPageEventArgs e)
            {
                Bitmap bitmap = MakeBarcodeImage(code, e.Graphics.DpiX, e.Graphics.DpiY, width, height, vertical);
                e.Graphics.PageUnit = System.Drawing.GraphicsUnit.Inch;
                e.Graphics.DrawImage(bitmap, ConvertInchToSm.FromMmToInches(left), ConvertInchToSm.FromMmToInches(top));
            }

            private Bitmap MakeBarcodeImage(string code, float dpiX, float dpiY, float? width, float? height, bool vertical)
            {
                BarCodeBuilder builder = new BarCodeBuilder(code, Symbology.EAN13);
                builder.GraphicsUnit = GraphicsUnit.Inch;
                builder.Resolution = new Resolution(dpiX, dpiY, ResolutionMode.Customized);
                builder.Margins.Bottom = 0;
                builder.Margins.Right = 0;
                builder.Margins.Top = 0;
                builder.Margins.Left = 0;
                builder.BorderVisible = false;
                builder.BorderWidth = 0;
                if (vertical)
                    builder.RotationAngleF = 90;
                builder.AutoSize = !height.HasValue || !width.HasValue;
                if (height.HasValue)
                {
                    builder.ImageHeight = height.Value / 25.4f;
                    builder.BarHeight = height.Value / 25.4f;
                }
                if (width.HasValue)
                {
                    builder.xDimension = width.Value / 25.4f  / 95f;
                    builder.ImageWidth = width.Value / 25.4f;
                }
                 return builder.GenerateBarCodeImage();
            } 

     
  •  09-03-2010, 2:39 PM 257040 in reply to 256837

    Re: Problem with BarCodeImage size .NET

    Hi,

    Thank you for inquiry.

    Could you please update the above program as follows to make it around 30mm x 18mm.

    builder.GraphicsUnit = GraphicsUnit.Millimeter;
    builder.ImageHeight = height;
    builder.BarHeight = height-1;
    builder.xDimension = 0.5f;
    builder.ImageWidth = width;

    The space between bars can be increased by incrementing the value of xDimension, but it crosses the 40mm limit, if I set xDimension to 0.6f. It is not always possible to perfectly generate the image according to the specified size.

    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
View as RSS news feed in XML