在C#winform的printdocument中断行 [英] Break line in printdocument in C# winform

查看:152
本文介绍了在C#winform的printdocument中断行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在每一个我尝试使用PrintDocuments Control制作客户收据时,现在我想在客户收据上显示页脚。 Foter Text存储在字符串类型Variable中。

字符串Fotertex =ABC DEF GHIJK LMNOP QRSTUVWXYZ AAA BBBBBBB ABCD;

但我使用热敏打印机进行客户收据。

和仅在foter中显示的文本是

hi every one i try to make Customer Receipts using PrintDocuments Control and now i want to display the footer on Customer Receipts. The Foter Text stored in a string type Variable.
String Fotertex="ABC DEF GHIJK LMNOP QRSTUVWXYZ AAA BBBBBBB ABCD";
but i use thermal printer for Customer Receipts.
and the text that display only in foter is "

ABC DEF GHIJK LMNOP



现在我希望它自动打破行和重命名文本

"
Now i want it automatically break the line and the renaming Text "

QRSTUVWXYZ AAA BBBBBBB ABCD

显示在下一行。

i只是想要文字字符大于19它会打破行并打印下一行重命名文字。

提前谢谢



我尝试了什么:



i尝试这个,但它不起作用我不知道为什么它不工作

" Display on Next line.
i simply want if the text Character greater then 19 it break the line and printer the renaming text in Next line.
Thanks in advance

What I have tried:

i try this but its not working i dont know why its not working

if (Fotertex.ToString().Length > 19)
          {
              graphics.DrawString(Fotertex.ToString().Substring(0, 19), myfont, Brushes.Black, new Point(10, startY = startY + 40));
          }

推荐答案

带有TextBlock或TextBox的表单或窗口(WPF)或使用Canvas定位或视觉到(bmp)成像的Text Wrapping On的RichTextBox将解决您的问题。这也允许您另存为PDF。
A "form" or "window" (WPF) with a TextBlock or TextBox or RichTextBox with "Text Wrapping On" using Canvas positioning or visual to (bmp) imaging will solve your problem. This will also allow you to "save as PDF".


这篇关于在C#winform的printdocument中断行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆