We have a HTML (see file) with a table and cells. Some of these cells have a different css-class. If you open the file in your browser you will see just one background-color.
But after we are inserting the html into a new document and save it as docx or pdf you will see a border around the color with the other background-color.
We are using Aspose.Words 16.6.0
2x Windows 10 64 Bit 1x Windows 7 64 Bit
Word 2013
Here is a Test Project:
<pre style=“color: rgb(0, 0, 0); font-family: “Courier New”;”>import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
/**
* Created by Alexander.Joerg on 03.08.2016.
*/
public class AsposeTest {
public static void main(String[] args) {
try {
Document document = new Document();
DocumentBuilder documentBuilder = new DocumentBuilder(document);
documentBuilder.insertHtml("\n" +
“<html lang=“en”>\n” +
“\n” +
" <meta charset=“UTF-8”>\n" +
" CSS-Test\n" +
“\n” +
“.Plan\n” +
“{\n” +
“\twidth: 109%;\n” +
“\tfont-size: 8pt;\n” +
“\ttext-align: right;\n” +
“\tborder-collapse: collapse;\t\n” +
“}\n” +
“\n” +
“.Plan thead\n” +
“{\n” +
“\ttext-align: center;\n” +
“\tborder: 1px solid #C8C8C8;\n” +
“}\n” +
“\n” +
“.Plan th\n” +
“{\n” +
“\tborder-left: 1px solid #C8C8C8;\n” +
“\tborder-right: 1px solid #C8C8C8;\n” +
“}\n” +
“\n” +
“.Plan td\n” +
“{\n” +
“\tborder: 1px solid #C8C8C8;\t\n” +
“}\n” +
“\n” +
“.PlanCurrentYear\n” +
“{\n” +
“\tbackground-color: #E6E6E6;\n” +
“}\n” +
“\n” +
“.PlanSubtotal\n” +
“{\n” +
“\tfont-weight: bold;\n” +
“\tbackground-color: lightgreen;\n” +
“}\n” +
“\n” +
“.PlanSum\n” +
“{\n” +
“\tfont-weight: bold;\n” +
“\tbackground-color: lightblue;\n” +
“}\n” +
“\n” +
“\n” +
“\n” +
“\n” +
“\n” +
“\n” +
“\t<table class=“Plan” >\n” +
“\t\t\n” +
“\t\t\n” +
“\t\t<col class=“PlanCurrentYear”>\n” +
“\t\t\n” +
“\t\t\n” +
“\t\t \n” +
“\t\t\t
\n” +
“\t\t\t\tHeadline
\n” +
“\t\t\t\tHeadline
\n” +
“\t\t\t\tHeadline
\n” +
“\t\t\t\tHeadline
\n” +
“\t\t\t\tHeadline
\n” +
“\t\t\t \n” +
“\t\t \n” +
“\t\t \n” +
“\t\t\t
Text
Text
Text
Text
Text
\n” +
“\t\t\t
Text
Text
Text
Text
Text
\n” +
“\t\t\t<tr class=“PlanSubtotal”>Text
Text
Text
Text
Text
\n” +
“\t\t\t<tr class=“PlanSum”>Text
Text
Text
Text
Text
\n” +
“\t\t\t
Text
Text
Text
Text
Text
\n” +
“\t\t\t
Text
Text
Text
Text
Text
\n” +
“\t\t\t \n” +
“\t\n” +
“\n” +
“\n” +
“”);
document.save(“C:\temp\testDocument.docx”);
document.save(“C:\temp\testDocument.pdf”);
} catch (Exception e) {
e.printStackTrace();
}
}
}
import com.aspose.words.DocumentBuilder;
/**
* Created by Alexander.Joerg on 03.08.2016.
*/
public class AsposeTest {
public static void main(String[] args) {
try {
Document document = new Document();
DocumentBuilder documentBuilder = new DocumentBuilder(document);
documentBuilder.insertHtml("\n" +
“<html lang=“en”>\n” +
“\n” +
" <meta charset=“UTF-8”>\n" +
" CSS-Test\n" +
“\n” +
“.Plan\n” +
“{\n” +
“\twidth: 109%;\n” +
“\tfont-size: 8pt;\n” +
“\ttext-align: right;\n” +
“\tborder-collapse: collapse;\t\n” +
“}\n” +
“\n” +
“.Plan thead\n” +
“{\n” +
“\ttext-align: center;\n” +
“\tborder: 1px solid #C8C8C8;\n” +
“}\n” +
“\n” +
“.Plan th\n” +
“{\n” +
“\tborder-left: 1px solid #C8C8C8;\n” +
“\tborder-right: 1px solid #C8C8C8;\n” +
“}\n” +
“\n” +
“.Plan td\n” +
“{\n” +
“\tborder: 1px solid #C8C8C8;\t\n” +
“}\n” +
“\n” +
“.PlanCurrentYear\n” +
“{\n” +
“\tbackground-color: #E6E6E6;\n” +
“}\n” +
“\n” +
“.PlanSubtotal\n” +
“{\n” +
“\tfont-weight: bold;\n” +
“\tbackground-color: lightgreen;\n” +
“}\n” +
“\n” +
“.PlanSum\n” +
“{\n” +
“\tfont-weight: bold;\n” +
“\tbackground-color: lightblue;\n” +
“}\n” +
“\n” +
“\n” +
“\n” +
“\n” +
“\n” +
“\n” +
“\t<table class=“Plan” >\n” +
“\t\t\n” +
“\t\t\n” +
“\t\t<col class=“PlanCurrentYear”>\n” +
“\t\t\n” +
“\t\t\n” +
“\t\t \n” +
“\t\t\t
“\t\t\t\t
“\t\t\t\t
“\t\t\t\t
“\t\t\t\t
“\t\t\t\t
“\t\t\t
“\t\t \n” +
“\t\t \n” +
“\t\t\t
“\t\t\t
“\t\t\t<tr class=“PlanSubtotal”>
“\t\t\t<tr class=“PlanSum”>
“\t\t\t
“\t\t\t
“\t\t\t \n” +
“\t\n” +
“\n” +
“\n” +
“”);
document.save(“C:\temp\testDocument.docx”);
document.save(“C:\temp\testDocument.pdf”);
} catch (Exception e) {
e.printStackTrace();
}
}
}