3

Maybe there is a simple solution to this but i cant seem to find one, i need to increase the height of the barcode without increasing font size.

                // Barcode Text Block
                TextBlock barcode = new TextBlock();
                barcode.Text = "12345678-123";
                barcode.FontFamily = new FontFamily("Free 3 Of 9");
                barcode.Margin = new Thickness(736, 638, 0, 50);
                barcode.FontSize = 65;
                page.Children.Add(barcode);

                // Baarcode Number Text Block
                TextBlock pageText = new TextBlock();
                string s = "*12345678-123*";
                s = s.Insert(1, " ").Insert(3, " ").Insert(5, " ").Insert(7, " ").Insert(9, " ").Insert(11, " ").Insert(13, " ").Insert(15, " ").Insert(17, " ").Insert(19, " ").Insert(21, " ").Insert(23, " ").Insert(25, " ");
                pageText.Text = s;

                pageText.FontFamily = new FontFamily("Arial");
                pageText.Margin = new Thickness(743, 685, 0, 50);
                pageText.FontSize = 26;          
                page.Children.Add(pageText);

It Currently looks like this:

enter image description here

I need the height of the barcode to be about 10pixels taller, without making it any wider. The height property didnt effect it.

zen_1991
  • 599
  • 1
  • 10
  • 27
  • You mean the height of the font characters? – Eugene Podskal Aug 20 '14 at 07:29
  • barcode.FontSize makes increases the size of the font which increases the barcode width and height. I want to keep the exact same width that it currently is but increase the height of it because currently the barcode is too thin. – zen_1991 Aug 20 '14 at 07:34
  • Well, I am not sure that it is possible with fonts(of course if you don't want to create your own), but maybe you can use ScaleTransform - http://stackoverflow.com/questions/4564709/wpf-on-mouse-hover-on-a-particular-control-increase-its-size-and-overlap-on-th. I just don't know how to make it constant(not trigger dependent). – Eugene Podskal Aug 20 '14 at 07:37
  • 1
    RenderTransform with ScaleTransform in Y direction may perhaps help here. – pushpraj Aug 20 '14 at 07:39
  • For those interested, one place the "Free 3 of 9" font can be located: https://www.barcodesinc.com/free-barcode-font/ – Bondolin Jul 19 '21 at 14:16

1 Answers1

7

here is a sample

// Barcode Text Block
TextBlock barcode = new TextBlock();
barcode.Text = "12345678-123";
barcode.FontFamily = new FontFamily("Free 3 Of 9");
barcode.Margin = new Thickness(736, 638, 0, 50);
barcode.FontSize = 65;
//apply scale
barcode.RenderTransform = new ScaleTransform() { ScaleY = 1.1 };

this transform will scale the bar-code element to 10 % extra height, you may adjust as per your needs.

pushpraj
  • 13,458
  • 3
  • 33
  • 50