【问题标题】:How to word wrap when printing through printdocument using vb.net使用 vb.net 通过 printdocument 打印时如何自动换行
【发布时间】:2019-07-12 08:54:04
【问题描述】:

我正在尝试使用 EPSON TM-T82 ReceiptSA4 热敏打印机(80 毫米卷)打印收据。但是在打印整个字符串时不会将其包裹在下一行中。

Private Sub prnLDocument_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles prnLDocument.PrintPage
        Dim sInvNo As String = "Explored the DrawString method and couldn't figure out how to do the automatic word wrap. Can you please. After setting the printer name, call IsValid to determine if the printer name is recognized as a valid printer on the system."

        Dim InvTitleFont As Font = New Font("Arial", 7, FontStyle.Regular)
        e.Graphics.DrawString(sInvNo, InvTitleFont, BlueBrush, 5, 20)
End Sub

Private Sub BillPrint()
        Try
            prnLDocument.PrinterSettings.PrinterName = "EPSON TM-T82 ReceiptSA4" 
            prnLPreview.Document = Me.prnLDocument
            prnLPreview.ShowDialog()
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        BillPrint()
End Sub

需要帮助如何解决此打印问题。

【问题讨论】:

标签: vb.net printdocument


【解决方案1】:
sInvNo.MaximumSize = New Size(100, 0)
sInvNo.AutoSize = True

把“100”改成最适合你的:)

【讨论】:

  • 我已将 sInvNo 作为字符串。这里提到的代码给出了一个错误。
  • 我用标签做到了,只需在表单中添加标签,然后通过代码更改标签的文本,否则您将不得不在字符串中添加手动中断,如下所示:“hello”& (vb.newline 或 vbCrLf) & “世界”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-06-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-06
相关资源
最近更新 更多