Hi,
If you open the attached document in MS Word, you can see the table with one row and two columns. In the first cell, there’s a Page break character at the beginning. If I reset it’s font formatting, apply font.getBorder().setLineStyle(LineStyle.NONE) and open the target file in Word 2016, I can notice the table structure is broken (Word 2013 shows it correctly).
However, I’ve managed to find what could be the problem. Check document.xml of the target file:
<w:r>
<span class=“button collapse-button” style=“user-select: none; cursor: pointer; display: inline-block; margin-left: -10px; width: 10px; background-image: url(“data:image/svg+xml,”); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: bottom; height: 10px;”><w:rPr>
<w:rStyle w:val=“DefaultParagraphFont”/>
<w:rFonts w:ascii=“Calibri” w:eastAsia=“Calibri” w:hAnsi=“Calibri” w:cs=“Arial”/>
<w:b w:val=“0”/>
<w:bCs w:val=“0”/>
<w:i w:val=“0”/>
<w:iCs w:val=“0”/>
<w:caps w:val=“0”/>
<w:smallCaps w:val=“0”/>
<w:strike w:val=“0”/>
<w:dstrike w:val=“0”/>
<w:outline w:val=“0”/>
<w:shadow w:val=“0”/>
<w:emboss w:val=“0”/>
<w:imprint w:val=“0”/>
<w:noProof w:val=“0”/>
<w:vanish w:val=“0”/>
<w:color w:val=“auto”/>
<w:spacing w:val=“0”/>
<w:w w:val=“100”/>
<w:kern w:val=“0”/>
<w:position w:val=“0”/>
<w:sz w:val=“22”/>
<w:szCs w:val=“22”/>
<w:highlight w:val=“none”/>
<w:u w:val=“none” w:color=“auto”/>
<w:bdr w:val=“nil”/>
<w:shd w:val=“clear” w:color=“auto” w:fill=“auto”/>
<w:vertAlign w:val=“baseline”/>
<w:rtl w:val=“0”/>
<w:cs w:val=“0”/>
<w:lang w:val=“fr-FR” w:eastAsia=“en-US” w:bidi=“ar-SA”/>
</w:rPr>
<w:br w:type=“page”/>
</w:r>
The value of <w:bdr> has been set to nil instead of none. If you manually change it to none, the table looks fine in the target file.
If I use LineStyle.NONE, Aspose.Words should set this value to none instead of nil.
Here’s the code:
String path = “Test.docx”;
Document document = new Document(path);
List runs = new ArrayList();
try {
document.accept(new DocumentVisitor() {
@Override
public int visitRun(Run run) throws Exception {
runs.add(run);
return super.visitRun(run);
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
DocumentBuilder documentBuilder = new DocumentBuilder(document);
documentBuilder.moveTo(runs.get(0));
documentBuilder.getFont().clearFormatting();
documentBuilder.getFont().getBorder().setLineStyle(LineStyle.NONE);
documentBuilder.write(ControlChar.PAGE_BREAK);
runs.get(0).remove();
document.save(“Test-aspose.docx”);
Can you check this?
Thanks,
Zeljko
Thanks,
Zeljko