itext将段落保持在一起

问题描述

| 我有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;
),并可能要调整已设置的任何填充物。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...