I created the attached file file (created_using_docs4j.looks_different_in_Word_2010_vs_2013.docx) using docx4j but it displays differently in Word2010 versus Word2013 - the table is orange in 2010 and green in 2013. Can someone help me understand why?
I tried updating my template file (I use a template file to get all the styles I need) to a .dotx created from Word 2013 (created_using_word.looks_same_in_both_word_versions.docx) - this file looks the same in both 2010 and 2013. When I compare this new/template file to my docx4j-generated file the document xml seems the same (except for some minor differences such as column widths and justification) but I notice that my docx4j-generated file has no theme.xml. I'm guessing this is the issue. I updated my addTemplateStyles method (see code below) to include themes and fonts but it seems that by default the newly created-by-docx4j file does not include themes so I'm not sure how to add a theme part to the MainDocumentPart (see my question marks below).
I hope this information is sufficient to explain my question. I thought I'd try to keep this post on the less-verbose side
Thanks for helping me understand!
Sharon
PS: The code I use to add styles from a template file is:
public static void addTemplateStyles(WordprocessingMLPackage wordMLPackage, File templateFile) throws Exception {
// Existing doc styles themes and fonts
MainDocumentPart actualDocPart = wordMLPackage.getMainDocumentPart();
StyleDefinitionsPart actualStyleDefinitionsPart = actualDocPart.getStyleDefinitionsPart();
ThemePart actualThemePart = actualDocPart.getThemePart();
if (actualThemePart == null) {
actualThemePart = new ThemePart();
// ???? How to attach it to actualDocPart ????
}
FontTablePart actualFontTablePart = actualDocPart.getFontTablePart();
// Add Template styles
WordprocessingMLPackage templateMLPackage = WordprocessingMLPackage.load(templateFile);
MainDocumentPart templateDocPart = templateMLPackage.getMainDocumentPart();
StyleDefinitionsPart templateStyleDefinitionsPart = templateDocPart.getStyleDefinitionsPart();
Styles templateStyles = templateStyleDefinitionsPart.getJaxbElement();
actualStyleDefinitionsPart.setJaxbElement(templateStyles);
// Add Template Themes <-- Adding this
ThemePart templateThemePart = templateDocPart.getThemePart();
Theme templateTheme = templateThemePart.getJaxbElement();
actualThemePart.setJaxbElement(templateTheme);
// Add Template Fonts <-- Adding this
FontTablePart templateFontTablePart = templateDocPart.getFontTablePart();
Fonts templateFonts = templateFontTablePart.getJaxbElement();
actualFontTablePart.setJaxbElement(templateFonts);
}