Hello, When saving document containing a table with specific “Keep with next” setup within cells, we get differences between generated Word and PDF content. In PDF the table is fitted into first page, while in Word it is placed on the second one. Here is a sample code snippet which allows to reproduce that issue:
Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
PageSetup pageSetup = builder.getPageSetup();
pageSetup.setOrientation(Orientation.PORTRAIT);
pageSetup.setPaperSize(PaperSize.CUSTOM);
pageSetup.setPageWidth(ConvertUtil.inchToPoint(4.13));
pageSetup.setPageHeight(ConvertUtil.inchToPoint(5.83));
builder.writeln("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eu urna lacinia velit congue hendrerit. In fringilla orci sodales risus viverra, eget suscipit mi aliquam. Aliquam erat volutpat. Maecenas finibus dolor nibh, eleifend molestie orci mollis in. Vivamus vitae turpis vitae ipsum auctor auctor sed in elit.");
builder.getCurrentParagraph().getParagraphFormat().setKeepWithNext(true);
builder.writeln("Table:");
builder.startTable();
for (int i = 1; i <= 7; i++)
{
builder.insertCell();
if (i == 7)
{
builder.getCurrentParagraph().getParagraphFormat().setKeepWithNext(false);
}
builder.write("Cell" + i);
builder.endRow();
}
builder.endTable();
document.save("Document.docx");
document.save("Document.pdf");