打印时自动换行 [英] Word Wrap while Printing

查看:94
本文介绍了打印时自动换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人遇到过一个不错的算法来实现.net打印中的自动换行功能?
功能?我有一个小组件,它使用基本的

打印技术(即

PrintDocument对象的PrintPage事件中的e.Graphics.DrawString)将一些格式化文本发送到打印机。但是,

如果线条太长,它们会跑掉页面而不是环绕。

我敢肯定我可以花时间想出一个字包装算法,但

想为什么要经历麻烦,如果有人已经知道一个:-)


---谢谢,杰夫


-


Jeff Bramwell

Digerati Technologies,LLC
www.digeratitech.com


使用Select-a-Net管理多个网络配置
< a rel =nofollowhref =http://www.select-a-net.comtarget =_ blank> www.select-a-net.com

解决方案

你好Jeff,


首先,我想确认一下我对你的问题的理解。从

你的描述,我知道你需要用自动换行打印文字。

如果有任何误解,请随时告诉我。


据我所知,如果你试图打印RTF文本,你可以使用旧的VB6控件使用

并将其包装为.net,或者你可以编写自己的代码。

您也可以使用MS Word Automation并将RichText复制到Word对象

,如果您有Word,则调用其打印方法。后者是最蹩脚的

方法,但它确实有效。


此外,还有一些第三方.NET组件。请尝试检查

以下链接:

http://www.codeguru.com/Csharp/Cshar...icle.php/c4781


Kevin Yu

=======

此帖子已提供按现状没有保证,并且不授予

权利。


你好Jeff,


如果你使用带有矩形的抽绳,它会为你自动换行。


g.DrawString(textbox1.text,textbox1.font,Brushes.Black,
RectangleF.op_Implicit(e.PageBounds))

Kevin Yu

=======

提供此帖子按原样提供没有保证,并且不授予

权利。


Jeff,


使用Graphics.DrawString方法时,其中一个参数是

StringFormat对象。这个对象定义了包装行为以及其他

的东西。

传递StringFormat对象定义和一个Rectangle对象来绘制

(而不是一个点) )作为Graphics.DrawString方法的参数和

它应该可以解决问题。


我一直这样做 - 除非我误解了你。


Picho

" Jeff B." < js*@community.nospam>在消息中写道

新闻:OW ************* @ TK2MSFTNGP15.phx.gbl ...

有没有人遇到过像样的人在.net打印中实现自动换行功能的算法?我有一个小组件,它使用基本的
打印技术(在PrintDocument对象的PrintPage事件中的ieeGraphics.DrawString)将一些格式化的文本发送到打印机。
但是,如果这些行太长了,他们跑出页面而不是环绕。我敢肯定我可以花时间想出一个包装算法的话,但想想为什么如果有人已经知道一个人就麻烦了:-)

---谢谢,杰夫



杰夫布拉姆威尔
Digerati Technologies,LLC
www.digeratitech.com

使用Select-a-Net管理多个网络配置
www.select-a-net.com



Has anyone come across a decent algorithm for implementing word wrap
features in .net printing? I have a small component that uses basic
printing techniques (i.e. e.Graphics.DrawString in a PrintPage event of a
PrintDocument object) to send some formatted text to the printer. However,
if the lines are too long they run off the page rather than wrapping around.
I''m sure I can spend the time and come up with a word wrapping algorithm but
figured why go through the trouble if someone already knows of one :-)

--- Thanks, Jeff

--

Jeff Bramwell
Digerati Technologies, LLC
www.digeratitech.com

Manage Multiple Network Configurations with Select-a-Net
www.select-a-net.com

解决方案

Hi Jeff,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to print text with word wrap.
If there is any misunderstanding, please feel free to let me know.

As far as I know, if you''re trying to print RTF text, you can either use
the old VB6 control and wrap it for .net, or you can write your own code.
You can also use MS Word Automation and copy the RichText to a Word object
and call its print method if you have Word. The latter is the lamest
approach, but it works.

Also, there are some 3rd party .NET components. Please try to check the
following link:

http://www.codeguru.com/Csharp/Cshar...icle.php/c4781

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Hi Jeff,

If you use a drawstring that takes a rectanglef it will word wrap for you.

g.DrawString(textbox1.text, textbox1.font, Brushes.Black,
RectangleF.op_Implicit(e.PageBounds))

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Jeff,

When working with the Graphics.DrawString method, one of the parameters is a
StringFormat object. this object defines wrapping behaviour among other
things.
pass the StringFormat object definitions and a Rectangle object to draw on
(rather than a Point) as parameters to the Graphics.DrawString method and
it should do the trick.

I do that all the time - unless I misunderstood you.

Picho
"Jeff B." <js*@community.nospam> wrote in message
news:OW*************@TK2MSFTNGP15.phx.gbl...

Has anyone come across a decent algorithm for implementing word wrap
features in .net printing? I have a small component that uses basic
printing techniques (i.e. e.Graphics.DrawString in a PrintPage event of a
PrintDocument object) to send some formatted text to the printer.
However, if the lines are too long they run off the page rather than
wrapping around. I''m sure I can spend the time and come up with a word
wrapping algorithm but figured why go through the trouble if someone
already knows of one :-)

--- Thanks, Jeff

--

Jeff Bramwell
Digerati Technologies, LLC
www.digeratitech.com

Manage Multiple Network Configurations with Select-a-Net
www.select-a-net.com



这篇关于打印时自动换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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