Code 39条形码

3
也许有一个简单的解决方案,但我似乎找不到。我需要增加条形码的高度而不增加字体大小。
                // 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);

当前它看起来是这样的:

enter image description here

我需要条形码的高度增加10像素,而不改变其宽度。使用height属性没有效果。


你是指字体字符的高度吗? - Eugene Podskal
barcode.FontSize可以增加字体的大小,从而增加条形码的宽度和高度。我想保持当前的宽度不变,但是增加高度,因为目前条形码太细了。 - zen_1991
嗯,我不确定使用字体是否可能(当然,如果您不想创建自己的字体),但也许您可以使用ScaleTransform - https://dev59.com/y1PTa4cB1Zd3GeqPfQOp。我只是不知道如何使其恒定(而不是触发器相关)。 - Eugene Podskal
1
在这里,使用Y方向的ScaleTransform进行RenderTransform可能会有所帮助。 - pushpraj
对于那些感兴趣的人,可以在以下位置找到“Free 3 of 9”字体:https://www.barcodesinc.com/free-barcode-font/ - Bondolin
1个回答

7

这里有一个示例

// 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 };

这个变换将会把条形码元素缩放到高度增加10%,您可以根据需要进行调整。

完美!这正是我在寻找的!谢谢! - zen_1991
太好了!愉快地编程吧 :) - pushpraj

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接