Hi,
we have a html with css. The table is formatted with border-collapse and border-spacing.
You can see that the word document has the required formatting. If we save the document as pdf, there is no border-spacing at all.
We are using Aspose.Words 16.11.0
2x Windows 10 64 Bit 1x Windows 7 64 Bit
Word 2013
Here is a Test Project:
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
/**
* Created by Alexander.Joerg on 09.11.2016.
*/
public class AsposeTest {
public static void main(String[] args) {
try {
String html = "\n" +
" #article {\n" +
" width: 100%;\n" +
" border-collapse: separate;\n" +
" border-spacing: 5px\n" +
" }\n" +
"\n" +
" #article td, #article th {\n" +
" font-size: 1em;\n" +
" border: 1px solid #98bf21;\n" +
" padding: 3px 7px 2px 7px;\n" +
" }\n" +
"\n" +
" #article th {\n" +
" font-size: 1.1em;\n" +
" text-align: left;\n" +
" padding-top: 5px;\n" +
" padding-bottom: 4px;\n" +
" background-color: #a7c942;\n" +
" color: #fff;\n" +
" }\n" +
"\n" +
" #article tr.alt td {\n" +
" color: #000;\n" +
" background-color: #eaf2d3;\n" +
" }\n" +
"\n" +
"<table id="article">\n" +
" \n" +
" Position \n" +
" Article \n" +
" Desc \n" +
" Tax \n" +
" Amount \n" +
" Unitcost\n \n" +
" TotalPrice \n" +
" \n" +
" <tr class="alt">\n" +
" 1 \n" +
" 0000001 \n" +
" Table \n" +
" 19,00 \n" +
" 1 ST \n" +
" 250 EUR \n" +
" 250 EUR \n" +
" \n" +
" \n" +
" 2 \n" +
" 0000002 \n" +
" Bench \n" +
" 19,00 \n" +
" 2 ST \n" +
" 100 EUR \n" +
" 200 EUR \n" +
" \n" +
" <tr class="alt">\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" **TotalPrice** \n" +
" **450 EUR** \n" +
" \n" +
"\n";
Document document = new Document();
DocumentBuilder documentBuilder = new DocumentBuilder(document);
documentBuilder.insertHtml(html);
document.save("C:\temp\testDocument.docx");
document.save("C:\temp\testDocument.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}