Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#或VB缩放发送到打印机的文本_C#_.net_Vb.net_Printing - Fatal编程技术网

C#或VB缩放发送到打印机的文本

C#或VB缩放发送到打印机的文本,c#,.net,vb.net,printing,C#,.net,Vb.net,Printing,我正在使用它将文本打印到标签打印机: Private Sub PrintTextControl_PrintPage( ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintTextControl.PrintPage '..... e.Graphics.DrawString("Hello World", font

我正在使用它将文本打印到标签打印机:

Private Sub PrintTextControl_PrintPage(
    ByVal sender As System.Object, 
    ByVal e As System.Drawing.Printing.PrintPageEventArgs) 
    Handles PrintTextControl.PrintPage
    '.....
    e.Graphics.DrawString("Hello World", font1, Brushes.Black, x, y, strFormat)
    '.....
End Sub
它工作得很好,除了标签打印机的标准字体很宽,甚至是“Arial窄字体”

我喜欢Arial/Sanserif风格的字体,因为它们干净清晰。我查看了第三方非标准字体,但没有发现任何Airal/Sanserif风格的干净清晰字体

有没有办法缩放文本以水平“挤压”它们?我不是说使用更小的字体,因为整个单词会变得更小。我希望它保持相同的高度,只需将其缩放得更窄。

试试这个:

Private Sub PrintTextControl_PrintPage(
    ByVal sender As System.Object, 
    ByVal e As System.Drawing.Printing.PrintPageEventArgs) 
    Handles PrintTextControl.PrintPage
    '.....
    Dim scaleMatrix As New Matrix()
    scaleMatrix.Scale(0.8, 1)
    e.Graphics.Transform = scaleMatrix
    e.Graphics.DrawString("Hello World", font1, Brushes.Black, x, y, strFormat)
    '.....
End Sub

只需将0.8替换为适合您打印机的刻度值。

这是wpf吗?对不起,忘了提了。这是一个动态链接库。为我们公司的Winform应用程序和web应用程序工作。太好了。看来这正是我需要的。我现在正在测试它。