确定文本字符串的行数? [英] Determining the number of lines in a text string?

查看:138
本文介绍了确定文本字符串的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为印刷类的一部分,我希望能够通过多页打印长字符串,但我不知道如何计算整个字符串,我会先计算行数确定的高度在我的字符串。我知道我可以指望换行的数量,但我也使用自动换行,所以每当一个行云过去页面宽度换行符将被添加。所以,我想我可以指望换行的数量,并计算出每条线的宽度,并找出是否有必要为每一行自动换行断行,但这似乎像一些过于复杂的问题我想可以更简单地完成。

  e.Graphics.DrawString(multiPageString,新的字体(宋体,12),Brushes.Black,新的RectangleF( 0,0,810,pageHeight)); 

如果您有任何建议,请让我知道谢谢!


< DIV CLASS =h2_lin>解决方案

我@大卫赫弗南同意提供一个真正的沼泽标准执行。其方式为复杂他们将要实现,或者用东西将产生100%可靠的打印效果等Reporting Services中去的价值。我觉得你的痛苦,印刷苦心!


As part of a printing class, I want to be able to print long strings over multiple pages, but I don't know how to calculate the height of the entire string, which I will determine by first counting the number of lines in my string. I know I can count the number of line breaks, but I am also using word-wrap, so line breaks will be added whenever a line goes on past the width of the page. So I suppose I could count the number of line breaks, and figure out the width of each line, and figure out if there is a need for a word-wrap line break for each line, but this seems like an overly complicated problem for something I imagine can be done more simply.

e.Graphics.DrawString(multiPageString, new Font("Courier New", 12), Brushes.Black, new RectangleF(0, 0, 810, pageHeight));

If you have any advice, please let me know thanks!

解决方案

I agree with @David Heffernan provide a really bog standard implementation. Its way to complicated for the value they are going to achieve, or go with something that will produce 100% reliable printing results etc Reporting Services. I feel your pain, printing is painstaking!

这篇关于确定文本字符串的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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