Search code examples
c#wpfcode39

Code 39 Barcodes


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.


Solution

  • 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.