Gembox.Documentでテーブルをドキュメントに挿入し、改ページで分割されないようにすることはできますが、前のページに収まらない場合は次のページに移動できますか? サンプルとドキュメントを調べましたが、何も見つかりませんでした。
1189 次
1 に答える
1
そのテーブルにある段落のKeepLinesTogether
プロパティKeepWithNext
を設定する必要があります。true
たとえば、次のことを試してください。
Table table = ...
foreach (ParagraphFormat paragraphFormat in table
.GetChildElements(true, ElementType.Paragraph)
.Cast<Paragraph>()
.Select(p => p.ParagraphFormat))
{
paragraphFormat.KeepLinesTogether = true;
paragraphFormat.KeepWithNext = true;
}
編集
上記はほとんどの場合に機能しますが、Table
要素に要素がない空の要素がTableCell
ある場合に問題が発生する可能性がありParagraph
ます。
このためには、目的のフォーマットを設定できるように、Paragraph
これらの要素に空の要素を追加する必要があります (出典: Keep Table on same page ):TableCell
// Get all Paragraph formats in a Table element.
IEnumerable<ParagraphFormat> formats = table
.GetChildElements(true, ElementType.TableCell)
.Cast<TableCell>()
.SelectMany(cell =>
{
if (cell.Blocks.Count == 0)
cell.Blocks.Add(new Paragraph(cell.Document));
return cell.GetChildElements(true, ElementType.Paragraph);
})
.Cast<Paragraph>()
.Select(p => p.ParagraphFormat);
// Set KeepLinesTogether and KeepWithNext properties.
foreach (ParagraphFormat format in formats)
{
format.KeepLinesTogether = true;
format.KeepWithNext = true;
}
于 2015-11-10T08:38:44.623 に答える