包装文字以适合打印文档中的标签 [英] Wrapping Text To Fit Tabs In Print Document

查看:67
本文介绍了包装文字以适合打印文档中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我目前正在阅读一个文本文件,并将对于页面而言太大的文本包装起来.我目前已经设置了制表符,但是当文本被换行时,它又从左边缘开始而不是缩进.我该如何解决?谢谢.

我已经尝试弄乱矩形参数的左边距,但是它只是将整个文本输入移开,而不仅仅是父行之后的换行.

Right now, I am currently reading in a text file and wrapping the text that is too big for a page. I currently have tabstops set up, but when the text is wrapped, it begins on the left margin again instead of the indent. How would I fix this? Thanks.

I have tried messing with the left margin in the rectangle''s parameters, but it just shifts the entire text entry over, not just the wrapped lines following the parent line.

// Calculate the number of lines per page.
            linesPerPage = ev.MarginBounds.Height /
                printFont.GetHeight(ev.Graphics);

            // Print each line of the file.
            while (lineNumber < linesPerPage &&
                ((line = streamToPrint.ReadLine()) != null))
            {
                StringFormat sf = StringFormat.GenericTypographic;
                sf.Alignment = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Near;
                sf.FormatFlags = StringFormatFlags.LineLimit;
                sf.Trimming = StringTrimming.Word;
                sf.SetTabStops(0.0f, tabStops);

                //Get dimensions of string
                actual = ev.Graphics.MeasureString(line, printFont,
                 new SizeF(ev.MarginBounds.Size.Width,
                      ev.MarginBounds.Size.Height), sf, out charCount, out lineCount);


                ev.Graphics.DrawString(line, printFont, Brushes.Black,
                new RectangleF(leftMargin, yPos, ev.MarginBounds.Size.Width,
                ev.MarginBounds.Size.Height), sf);

                //Add rectangle height to Y position
                yPos += actual.Height;

推荐答案

您需要从一个制表符开始创建一个缩进距离比边距更远的缩进.第一行无法比其余行更靠前,除非您先计算一行中可以容纳多少文本,然后将剩余的行放在第一行之后的新矩形中.
You need to start with a tab to create an indent that is further in than the margin. There''s no way for the first line to stick further left than the rest, without you calculating how much text fits on a line and then putting the rest after the first line in a new rectangle.


; P:laugh::):confused:X | :cool:
;P :laugh: :) :confused: X| :cool:


这篇关于包装文字以适合打印文档中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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