Hi,
there is a mistake with colors of shading for odt. A little test example
public static void main(String[] args)
{
try
{
LicenseReader.getLizenz();
testColor();
testReadColor();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private static void testColor() throws Exception
{
// Open the template document.
Document doc = new Document();
DocumentBuilder db = new DocumentBuilder(doc);
db.writeln("Erster Absatz");
db.writeln("Zweiter Absatz");
int i = 0;
for (com.aspose.words.Section sec: doc.getSections())
{
// EinfΣrben der smartDoc-Bereiche
ParagraphCollection pcol = sec.getBody().getParagraphs();
for (Paragraph p: pcol)
{
Shading shading = p.getParagraphFormat().getShading();
if (i % 2 == 0)
{
shading.setTexture(TextureIndex.TEXTURE_SOLID);
shading.setForegroundPatternColor(Color.red);
System.out.println(p.getText() +" red Foreground "+ shading.getForegroundPatternColor() +" Background "+ shading.getBackgroundPatternColor());
} else {
shading.setTexture(TextureIndex.TEXTURE_SOLID);
shading.setBackgroundPatternColor(Color.blue);
System.out.println(p.getText() +" blue Foreground "+ shading.getForegroundPatternColor() +" Background "+ shading.getBackgroundPatternColor());
}
i++;
}
}
doc.save(path + "color_test.odt", SaveFormat.ODT);
}
private static void testReadColor() throws Exception
{
// Open the template document.
Document doc = new Document(path + "color_test.odt");
for (com.aspose.words.Section sec: doc.getSections())
{
// EinfΣrben der smartDoc-Bereiche
ParagraphCollection pcol = sec.getBody().getParagraphs();
for (Paragraph p: pcol)
{
Shading shading = p.getParagraphFormat().getShading();
System.out.println(p.getText() +" Foreground "+ shading.getForegroundPatternColor() +" Background "+ shading.getBackgroundPatternColor());
}
}
}
Output with SaveFormat.ODT
Erster Absatz
red Foreground java.awt.Color[r=255,g=0,b=0] Background java.awt.Color[r=0,g=0,b=0]
Zweiter Absatz
blue Foreground java.awt.Color[r=0,g=0,b=0] Background java.awt.Color[r=0,g=0,b=255]
red Foreground java.awt.Color[r=255,g=0,b=0] Background java.awt.Color[r=0,g=0,b=0]
Erster Absatz
Foreground java.awt.Color[r=0,g=0,b=0] Background java.awt.Color[r=255,g=0,b=0]
Zweiter Absatz
Foreground java.awt.Color[r=0,g=0,b=0] Background java.awt.Color[r=0,g=0,b=0]
Foreground java.awt.Color[r=0,g=0,b=0] Background java.awt.Color[r=255,g=0,b=0]
Output with only differenz in SaveFormat.DOC
Erster Absatz
red Foreground java.awt.Color[r=255,g=0,b=0] Background java.awt.Color[r=0,g=0,b=0]
Zweiter Absatz
blue Foreground java.awt.Color[r=0,g=0,b=0] Background java.awt.Color[r=0,g=0,b=255]
red Foreground java.awt.Color[r=255,g=0,b=0] Background java.awt.Color[r=0,g=0,b=0]
Erster Absatz
Foreground java.awt.Color[r=255,g=0,b=0] Background java.awt.Color[r=0,g=0,b=0]
Zweiter Absatz
Foreground java.awt.Color[r=0,g=0,b=0] Background java.awt.Color[r=0,g=0,b=255]
Foreground java.awt.Color[r=255,g=0,b=0] Background java.awt.Color[r=0,g=0,b=0]
Which I also expected for odt. The the odt-document opened with OpenOffice is black and not blue.
The information about blue is gone. And the red-Color could only be found in Background after saving it, expected would be Foreground.
I need to set the backgroundColor for doc and odt and after saving it need to be possible to reset the paragraph-shading.
Tanks.