问题描述
|
我有2个段落对象,约占页面的2/3。当我在pdf中查看时,第二段的开头从第二页开始。有没有办法在第一段之后的第一页上启动它?
PdfPTable rs1 = new PdfPTable(1);
PdfPCell c = new PdfPCell();
c.MinimumHeight = 36f;
Paragraph p = new Paragraph(
\"some text to align\\n\" +
\"...\" +
\"some text to align\\n\"
);
c.AddElement(p);
rs1.AddCell(c);
PdfPCell c2 = new PdfPCell();
c.MinimumHeight = 36f;
Paragraph p2 = new Paragraph(
\"some text to align\\n\" +
\"...\" +
\"some text to align\\n\" +
\"some text to align\\n\"
);
p2.KeepTogether = false;
c2.AddElement(p2);
c2.VerticalAlignment = Element.ALIGN_TOP;
rs1.AddCell(c2);
return rs1;
解决方法
我使用了PdfPTable.SplitLate = false
, 问题不在于段落,而在于表格。 iTextSharp尝试不破坏表单元格之间的内容,并且您当前的布局似乎可以做到这一点。你需要一张桌子吗?当一行超出可见区域时,常规段落会中断。如果需要桌子,则必须调整桌子的宽度(
rs1.WidthPercentage = 100;
),并可能要调整已设置的任何填充物。