Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# itext将段落放在一起_C#_Itextsharp_Itext - Fatal编程技术网

C# itext将段落放在一起

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" + ".

我有两个段落对象,占据了页面的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" +
        "..." +
        "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