Hello,
Back in May i reported issue with Word vs PDF mismatch while merging columns and using page break before paragraph setting. It was under link Word and Pdf mismatch. It was fixed, but it appears that while extending this case with more paragraph settings it is still reproducible. I’m adding a code snippet that generating spoiled docx. In terms of saving it as pdf we are ending up with part of text not moved into new page.
Samle code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.startTable();
builder.getParagraphFormat().clearFormatting();
builder.getParagraphFormat().setWidowControl(true);
builder.getParagraphFormat().setKeepWithNext(true);
builder.insertCell();
builder.write("1");
builder.insertCell();
builder.endRow();
builder.insertCell();
builder.getParagraphFormat().clearFormatting();
builder.getParagraphFormat().setWidowControl(true);
builder.write("2");
builder.insertCell();
builder.getParagraphFormat().clearFormatting();
builder.getParagraphFormat().setWidowControl(true);
builder.getParagraphFormat().setKeepWithNext(true);
builder.write("1111111111");
builder.writeln();
builder.write("Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. "
+ "Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. Text in merged cells. ");
builder.endRow();
builder.insertCell();
builder.getParagraphFormat().clearFormatting();
builder.getParagraphFormat().setWidowControl(true);
builder.getParagraphFormat().setPageBreakBefore(true);
builder.write("3");
builder.insertCell();
builder.endRow();
builder.insertCell();
builder.getParagraphFormat().clearFormatting();
builder.getParagraphFormat().setWidowControl(true);
builder.getParagraphFormat().setKeepWithNext(true);
builder.write("4");
builder.insertCell();
builder.endRow();
builder.insertCell();
builder.getParagraphFormat().clearFormatting();
builder.getParagraphFormat().setWidowControl(true);
builder.write("5");
builder.insertCell();
builder.endRow();
builder.endTable();
table.getRows().get(1).getCells().get(1).getCellFormat().setVerticalMerge(CellMerge.FIRST);
table.getRows().get(2).getCells().get(1).getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
doc.save("doc.docx", saveOptions);
asposeWordVersion: ‘23.8’