Applied lining in word with tab stops it works fine, but when the file has custom list items it was breaking the words
thus had applied following solution to fix
Document doc = new Document("C:\\Temp\\Final_linedDoc.docx");
for(Paragraph p : (Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH, true))
{
if(p.isListItem())
p.getListFormat().getListLevel().setTrailingCharacter(ListTrailingCharacter.SPACE);
}
doc.save("C:\\Temp\\out.docx");
although after applying this there was another issue introduced as adding extra space for the list items as below
to check if the trailing space was causing issue, I have changed the above solution and replaced with following code to add tabstops
Document doc = new Document("C:\\Temp\\Final_linedDoc.docx");
for(Paragraph p : (Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH, true)) {
if (p.isListItem()) {
p.getParagraphFormat().getTabStops().add(doc.getDefaultTabStop(), TabAlignment.LEFT, TabLeader.NONE);
p.getParagraphFormat().getTabStops().add(doc.getDefaultTabStop() * 2, TabAlignment.LEFT, TabLeader.NONE);
p.getParagraphFormat().getTabStops().add(doc.getDefaultTabStop() * 3, TabAlignment.LEFT, TabLeader.NONE);
}
}
doc.save("C:\\Temp\\out_tab.docx");
Even with this solution the additional space is still available.
here is the Original document without lining
T-1-Original-Document-1.en.docx (21.4 KB)
Document without any solution after applying lining with word breaking -
T-1-Original-Document-1.nl.en Minuut (1)-With-Word-Break.docx (24.8 KB)
Document after lining with trailing space solution -
T-1-Original-Document-1.nl.en Minuut (2)-Space-Trailing-Solution.docx (24.8 KB)
Document after lining with adding additional tab stop solution -
T-1-Original-Document-1.en Minuut - with-extra-tab-stop-solution.docx (24.8 KB)
Thus even with either additional tab stop or space trailing solution the extra space is added. so we need a combined solution which doesn’t break the word and doesn’t add extra space either.
We are using a license version with library aspose-words:21.2:jdk17