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);

它目前看起来像这样:

在此处输入图像描述

我需要条码的高度大约高 10 像素,而不使其更宽。高度属性没有影响它。

4

1 回答 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 % 的额外高度,您可以根据需要进行调整。

于 2014-08-20T07:40:11.167 回答