有谁知道如何在可能位于页面上随机位置的标题(粗体文本的短行)下画一条线。
例如,
My Heading 1
----------------------------------------------
Some random paragraph
My Heading 2
----------------------------------------------
我可以像上面那样使用一行下划线 _ 来完成此操作,但是为了使该行靠近标题,我必须将字体大小设置为 2,这会导致一条参差不齐的丑陋线条。
我还可以在彼此的顶部添加两个块(一个带有标题,一个带有 _),类似于本文中的第一个示例 http://www.mikesdotnetting.com/Article/82/iTextSharp-Adding-Text-with-Chunks-Phrases-and-Paragraphs 使用相同的字体大小,但似乎这只是在页面顶部工作,一旦我添加其他段落并尝试在页面中间进行操作,两个块就会分开,并在第一个块的末尾有一个清晰的换行符。
似乎你可以在 iTextSharp 中画线,但我不知道如何计算坐标,因为我见过的所有示例都使用此方法在页面顶部或底部的固定位置放置一条线。
非常感谢任何帮助。
干杯
抢
does anyone know how I can draw a line under a heading (a short line of bold text) that may be located in a random location on a page.
e.g.
My Heading 1
----------------------------------------------
Some random paragraph
My Heading 2
----------------------------------------------
I can do it as I have done above using a line of Underscores _ but in order to get the line anywhere near the heading I have to set the font size at 2 which results in a spotty ugly line.
I can also add two chunks over the top of each other (one with the heading and one with _) similar to the first example in this article http://www.mikesdotnetting.com/Article/82/iTextSharp-Adding-Text-with-Chunks-Phrases-and-Paragraphs using the same font size but it seems that this only works at the top of the page, once I add other paragraphs and try to do it mid-way down the page the two chunks separate with a clear line-break at the end of the first chunk.
It seems you can draw lines in iTextSharp but I have no idea how to calculate the coordinates, as all the examples I have seen use this method to place a line at the top or bottom of the page in a fixed location.
Any help greatly appreciated.
Cheers
Rob
发布评论
评论(2)
LineSeperator 对象可能就是您正在寻找的对象。用一块包裹它并将其放在您需要的地方。
这是行分隔符示例:
The LineSeperator object might be what you're looking for. Wrap it with a chunk and put it where you need it.
Here's a sample line seperator:
我知道这是一篇较旧的帖子,但是也许这会对某人有所帮助。
I know this is an older post but, maybe this will help somebody.