由AddFOrmattedText添加的文本中间的MigraDoc分页符(MigraDoc page break in middle of Text added by AddFOrmattedText

编程入门 行业动态 更新时间:2024-10-20 08:45:06
由AddFOrmattedText添加的文本中间的MigraDoc分页符(MigraDoc page break in middle of Text added by AddFOrmattedText)

我用MigraDoc创建PDF文档。 我为所有页面添加了一个完整大小的“标题”:

Image bg = section.Headers.FirstPage.AddImage(@"\\server\header.bmp"); bg.Height = "29.7cm"; bg.Width = "21cm"; bg.RelativeVertical = RelativeVertical.Page; bg.RelativeHorizontal = RelativeHorizontal.Page; bg.WrapFormat.Style = WrapStyle.Through;

现在我想将文本框中的文本添加到该页面:

Paragraph paragraph = section.AddParagraph(); paragraph.Format.SpaceBefore = "7.5cm"; paragraph.Format.SpaceAfter = "5"; paragraph.Format.Font.Color = Color.FromCmyk(100, 100, 100, 100); FormattedText ft = paragraph.AddFormattedText(this.gMailItem.Body);

我遇到的问题是我添加的文本可能比一页更大。 如果发生这种情况,文本将打印在“全尺寸标题”/文具上。 有没有办法限制文档的高度(强制分页)?

编辑:这是我的问题的图片: http : //img4host.net/upload/1014244953be8611defa9.PNG

Im creating a PDF-Document with MigraDoc. I added a full size "Header" to all Pages:

Image bg = section.Headers.FirstPage.AddImage(@"\\server\header.bmp"); bg.Height = "29.7cm"; bg.Width = "21cm"; bg.RelativeVertical = RelativeVertical.Page; bg.RelativeHorizontal = RelativeHorizontal.Page; bg.WrapFormat.Style = WrapStyle.Through;

Now i want to add Text from a Textbox to that Page:

Paragraph paragraph = section.AddParagraph(); paragraph.Format.SpaceBefore = "7.5cm"; paragraph.Format.SpaceAfter = "5"; paragraph.Format.Font.Color = Color.FromCmyk(100, 100, 100, 100); FormattedText ft = paragraph.AddFormattedText(this.gMailItem.Body);

The problem i have is that the text Im adding could be bigger than one page is. If this happens, the text is printed over the "full size header"/stationery. Is there a way to limit the height of a Document (to force a page break)?

EDIT: Here is a picture of my problem: http://img4host.net/upload/1014244953be8611defa9.PNG

最满意答案

文档的“客户区”由页面大小和边距(顶部,底部,左侧,右侧)定义,MigraDoc将在此区域已满时添加分页符。

我不完全明白问题是什么,但可能你必须增加上边距(而不是将SpaceBefore设置为7.5厘米 - SpaceBefore只在段落的开头工作,而TopMargin适用于每个新页面)。

编辑:另见: 发表于PDFsharp论坛

The "client area" of the document is defined by the page size and the margins (top, bottom, left, right) and MigraDoc will add page breaks when this area is full.

I do not fully understand what the problem is, but probably you have to increase the top margin (instead of setting SpaceBefore to 7.5 cm - SpaceBefore works only at the start of the paragraph while TopMargin works for each new page).

Edit: See also: Post in PDFsharp Forum

更多推荐

本文发布于:2023-08-06 22:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456625.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分页   文本   MigraDoc   AddFOrmattedText   page

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!