Examples of MainDocumentPart


Examples of org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart

   
    WordprocessingMLPackage wordMLPackage=null;
    try {
      wordMLPackage = WordprocessingMLPackage.createPackage();
    } catch (InvalidFormatException e) {}
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
   
    // Main Document Part
    mdp.getJaxbElement().setBody(transitionContainer.getBody());
   
    // DEBUGGING: if Word can't open the resulting docx,
    // a process for working out why is to
    // make sure it works with just the main document part,
    // then each of the following 3 parts, one by one.
    // What you need to do is to compare the XSLT output for the part
    // (XmlUtils.marshaltoString for the relevant part is usually
    //  enough) to what ECMA 376 requires.
    if (!mainDocOnly) {
   
      // Styles
      mdp.getStyleDefinitionsPart(true).setJaxbElement(transitionContainer.getStyles());
     
      // Numbering
      try {
        NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
        ndp.setJaxbElement(transitionContainer.getNumbering());
        mdp.addTargetPart(ndp);
       
        // fix attributes
        // <w:multiLevelType w:val="Multilevel"/> should start with lower case
        for (AbstractNum anum : ndp.getJaxbElement().getAbstractNum()) {
          if (anum.getMultiLevelType()==null) continue;
          String multiLevelType = anum.getMultiLevelType().getVal();
          multiLevelType = multiLevelType.substring(0, 1).toLowerCase() + multiLevelType.substring(1);
          anum.getMultiLevelType().setVal(multiLevelType);
        }
       
      } catch (InvalidFormatException e) {}
     
      // Fonts
      try {
        FontTablePart fontsPart = new FontTablePart();
        fontsPart.setJaxbElement(transitionContainer.getFonts());
               
        mdp.addTargetPart(fontsPart);
      } catch (InvalidFormatException e) {}
    }
   
    return wordMLPackage;
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.