C# itext将段落放在一起
我有两个段落对象,占据了页面的2/3。当我在pdf中查看它时,第2段的开头从第2页开始。有没有办法从第一段后面的第一页开始C# itext将段落放在一起,c#,itextsharp,itext,C#,Itextsharp,Itext,我有两个段落对象,占据了页面的2/3。当我在pdf中查看它时,第2段的开头从第2页开始。有没有办法从第一段后面的第一页开始 PdfPTable rs1 = new PdfPTable(1); PdfPCell c = new PdfPCell(); c.MinimumHeight = 36f; Paragraph p = new Paragraph( "some text to align\n" + ".
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;
问题不在于你的段落,而在于你的表格。iTextSharp尝试不在表格单元格中打断内容,而您当前的布局似乎就是这样做的。你需要一张桌子吗?当一行离开可视区域时,常规段落将刚好中断。如果您需要表格,则必须尽可能调整表格的宽度(
rs1.WidthPercentage=100;
)以及可能设置的任何填充。我使用了PdfPTable.SplitLate=false