Page 1 of 1

File corrupted when creating from sample

PostPosted: Thu Feb 11, 2016 10:35 pm
by Zezombye
I'm creating a word document from the CreateWordprocessingMLDocument.java sample, it works fine but word 2007 says it's corrrupted. Wordpad opens it but says there are elements it can't show.

Here's the xml:

Code: Select all
<w:document xmlns:dsp="http://schemas.microsoft.com/office/drawing/2008/diagram" xmlns:odx="http://opendope.org/xpaths" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:odgm="http://opendope.org/SmartArt/DataHierarchy" xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:ns31="http://schemas.openxmlformats.org/drawingml/2006/compatibility" xmlns:ns30="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" xmlns:ns9="http://schemas.openxmlformats.org/schemaLibrary/2006/main" xmlns:ns12="http://schemas.openxmlformats.org/drawingml/2006/chartDrawing" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:ns32="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" xmlns:ns17="urn:schemas-microsoft-com:office:excel" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:oda="http://opendope.org/answers" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:odc="http://opendope.org/conditions" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:ns23="http://schemas.microsoft.com/office/2006/coverPageProps" xmlns:odi="http://opendope.org/components" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:ns21="urn:schemas-microsoft-com:office:powerpoint" xmlns:odq="http://opendope.org/questions">
    <w:body>
        <w:p>
            <w:pPr>
                <w:pStyle w:val="Title"/>
            </w:pPr>
            <w:r>
                <w:t>Example 1</w:t>
            </w:r>
        </w:p>
        <w:p>
            <w:r>
                <w:t>Example 2</w:t>
            </w:r>
        </w:p>
        <w:p>
            <w:pPr>
                <w:rPr/>
            </w:pPr>
            <w:r>
                <w:rPr>
                    <w:b w:val="true"/>
                </w:rPr>
                <w:t>Example 3a (bold)</w:t>
            </w:r>
        </w:p>
        <w:p>
            <w:r>
                <w:rPr>
                    <w:b w:val="true"/>
                </w:rPr>
                <w:t>Example 3b (bold)</w:t>
            </w:r>
        </w:p>
        <w:p>
            <w:r>
                <w:rPr>
                    <w:b/>
                </w:rPr>
                <w:t>Example 4</w:t>
            </w:r>
        </w:p>
        <w:tbl>
            <w:tblPr>
                <w:tblStyle w:val="TableGrid"/>
                <w:tblW w:w="0" w:type="auto"/>
                <w:tblLook w:val="04A0"/>
            </w:tblPr>
            <w:tblGrid>
                <w:gridCol w:w="3120"/>
                <w:gridCol w:w="3120"/>
                <w:gridCol w:w="3120"/>
            </w:tblGrid>
            <w:tr>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
            </w:tr>
            <w:tr>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
            </w:tr>
            <w:tr>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
                <w:tc>
                    <w:tcPr>
                        <w:tcW w:w="3120" w:type="dxa"/>
                    </w:tcPr>
                    <w:p/>
                </w:tc>
            </w:tr>
        </w:tbl>
        <w:sectPr>
            <w:pgSz w:w="12240" w:h="15840" w:code="1"/>
            <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"/>
        </w:sectPr>
    </w:body>
</w:document>


What should I do?

Re: File corrupted when creating from sample

PostPosted: Fri Feb 12, 2016 12:17 am
by menschguenther
no errors from word 2007 on my side

have you tried a blank doc?

Code: Select all
public class CreateWordprocessingMLDocument extends AbstractSample {

   public static void main(String[] args) throws Exception {
      
            
      boolean save = true;

      WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
      MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();

         // Pretty print the main document part
      System.out.println(
            XmlUtils.marshaltoString(mdp.getJaxbElement(), true, true) );
      
      // Optionally save it
      if (save) {
         String filename = System.getProperty("user.dir") + "/OUT_CreateWordprocessingMLDocument.docx";
         wordMLPackage.save(new java.io.File(filename) );
         System.out.println("Saved " + filename);
      }
                  
   }
   
}

Re: File corrupted when creating from sample

PostPosted: Fri Feb 12, 2016 5:08 am
by Zezombye
Nope, blank document doesn't work either. Maybe it's my version of word? Here's my 2 documents, send yours so that I can see if word opens it or not.

Re: File corrupted when creating from sample

PostPosted: Fri Feb 12, 2016 9:15 pm
by menschguenther
both files work

Re: File corrupted when creating from sample

PostPosted: Sat Feb 13, 2016 2:14 am
by Zezombye
Well it's weird because word opens your file just fine, which was created using exactly the same method as me o_o

Send your XML to see if it's the same? If it's the same it would be weird.

Re: File corrupted when creating from sample

PostPosted: Mon Feb 15, 2016 4:38 pm
by jason

Re: File corrupted when creating from sample

PostPosted: Mon Feb 15, 2016 5:47 pm
by Zezombye
Thanks, it was that :D changed the version from 3.1.0 to 3.3 and it works just fine.