Page 1 of 1

Word 2003: Not able to open docx file

PostPosted: Wed Nov 05, 2014 6:41 pm
by aguna
The document is not getting opened in lower version(MS word below 2010)
Clients are not ready to upgrade MS word.
Kindly let me know is there any alternate to open the doc created by docx4j in lower version itself.
Please assit on the above

Re: Not able to open docx file created by docx4j in lowerver

PostPosted: Tue Nov 11, 2014 1:39 pm
by jason
Should work in Word 2007

What happens? Can you post a sample docx which doesn't work?

Maybe the w14, w15 attributes is the main cause of problems in Word 2007. Google "Microsoft Office Compatibility Pack for Word". If that's not an option, we can look at adding a setting which avoids adding those (see MainDocumentPartMceIgnorableHelper)

Re: Not able to open docx file created by docx4j in lowerver

PostPosted: Wed Nov 12, 2014 8:09 pm
by aguna
After running the exe :Microsoft Office Compatibility Pack for Word.The document is not opening in word 2003

Tried the below one also.its not working.Kindly help me out.

Code: Select all
String stringFromFile = FileUtils.readFileToString(new File(destFolder
               + "/" + xhtmlFileName), "UTF-8");
         WordprocessingMLPackage docxOut = WordprocessingMLPackage
               .createPackage();

         AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(
               new PartName("/hw.html"));
         afiPart.setBinaryData(stringFromFile.getBytes());
         afiPart.setContentType(new ContentType("text/html"));
         Relationship altChunkRel = docxOut
               .getMainDocumentPart().addTargetPart(
                     afiPart);
         
         // .. the bit in document body
         CTAltChunk ac = Context.getWmlObjectFactory()
               .createCTAltChunk();
         ac.setId(altChunkRel.getId());
         docxOut.getMainDocumentPart().addObject(ac);
         // .. content type
         docxOut.getContentTypeManager()
               .addDefaultContentType("html", "text/html");
   
         customizeDocx(docxOut);
         
         MainDocumentPartMceIgnorableHelper mdhelper=new MainDocumentPartMceIgnorableHelper();
         
         Document wmlDocumentEl = (Document) docxOut.getMainDocumentPart()
               .getContents();
         Body body = wmlDocumentEl.getBody();
         mdhelper.getMceIgnorable(body);
         
         
         docxOut.save(new File(destFolder + "/" + docxFileName));


The usage of MainDocumentPartMceIgnorableHelper is correct.?Let me know if I m going wrong anywhere.

Re: Not able to open docx file created by docx4j in lowerver

PostPosted: Fri Nov 14, 2014 6:57 pm
by jason
Manually unzip the docx created by docx4j, and remove the w14 and w15 attributes in word/document.xml, then zip up again.

See whether the result opens in Word 2003

Re: Not able to open docx file created by docx4j in lowerver

PostPosted: Sat Nov 15, 2014 12:44 am
by aguna
In the word/document.xml

I have mc:Ignorable=""

and few more things http://schemas.openxmlformats.org/wordprocessingml/2006/main

2006 is mentioned in xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"

I changed all the 2006 to 2003 and opened the document.
Its throws error ,the file was created in earlier beta version of word 2007 and it cannot be opened in this version.

Re: Not able to open docx file created by docx4j in lowerver

PostPosted: Sat Nov 15, 2014 7:58 am
by jason
You shouldn't need to change the 2006 namespace with the compatibility pack installed.

My suggestion was to look at the w14, w15 namespaced attributes. Can't help further unless you do that or upload sample problematic docx.

Edit

Look at the first w:p in your docx, for the following:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<w:document  mc:Ignorable="w14 w15">
    <w:body>
        <w:p w14:paraId="11188b9" w14:textId="11188b9">
            <w:pPr>
                <w15:collapsed w:val="false"/>
            </w:pPr>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Delete those then see whether it works. By rights, it shouldn't make any difference (if the compatibility pack is indeed adding support for mc:Ignorable). If it doesn't work, try deleting mc:Ignorable as well.

See further "Microsoft Office Document Format Compatibility and Extensibility" at http://msdn.microsoft.com/en-us/library/gg482166.aspx

People still use Word 2007 (and docx4j should create documents Word 2007 can read), but I'm afraid you're largely on your own with Word 2003.

Re: Not able to open docx file created by docx4j in lowerver

PostPosted: Mon Nov 17, 2014 3:01 pm
by aguna
Me too not satisfied with word 2003,but clients are not ready to upgrade :(

Have attached the document.xml generated while unzipping the docx.
Kindly help me.

Re: Not able to open docx file created by docx4j in lowerver

PostPosted: Mon Nov 17, 2014 3:24 pm
by aguna
PFA the sample docx file

Re: Word 2003: Not able to open docx file

PostPosted: Mon Nov 17, 2014 5:15 pm
by jason
OK, the problem is that Word 2003 can't handle altChunk.

You can google 'word 2003 altchunk', but see Eric's post at http://openxmldeveloper.org/discussions ... 31640.aspx
and https://social.msdn.microsoft.com/Forum ... ffice-2003

You can use docx4j-ImportXHTML instead of relying on Word.

Re: Word 2003: Not able to open docx file

PostPosted: Mon Nov 17, 2014 5:39 pm
by aguna
I have tried with xhtmlImporter.Its working in Word 2003.
But having few alignemnet issue,which is not there when i use altChunk and open the doc in Word 2010 .

The <hr/> is not getting dispalyed when xhtmlImporter is used.
Kindly help.

Re: Word 2003: Not able to open docx file

PostPosted: Mon Nov 17, 2014 7:00 pm
by aguna
http://www.docx4java.org/forums/docx-java-f6/tip-constructing-complex-objects-t7.html
I have seen the code to add horizontal line.

docx4j will not identify the horizontal line from html and directly convert (while saving it as docx using xhtmlImporter).
I m using docx4j 3.2.1 AND docx4j-XHTMLImporter 3.2.1 version.
Apart from these 2 dependecy (maven) anything else need to added for the exact conversion.

Re: Word 2003: Not able to open docx file

PostPosted: Tue Nov 18, 2014 9:03 am
by jason

Re: Word 2003: Not able to open docx file

PostPosted: Tue Nov 18, 2014 3:50 pm
by aguna
Hi jasaon,

Thanks a lot .The issue got fixed.

As of now for testing purpose i attached the src and did it.
I m using maven.In pom.xml
How i need to specify to get the corresponding jar download.

Re: Word 2003: Not able to open docx file

PostPosted: Wed Nov 19, 2014 11:51 pm
by aguna
When are u planning to release the jar with the fix made to xhtmlimporter

Re: Word 2003: Not able to open docx file

PostPosted: Thu Nov 20, 2014 10:47 am
by jason
Hello Aguna

I don't have any firm plans to release a new version of XHTMLImporter right now.

That said, as a service to Plutext's commercial customers, we do publish jars "on-demand".

I know I've pointed this out to you before, but support in this forum is on an "as we feel like it" basis. I've noticed you have a number of specific requirements, some of which aren't at the top of my priority list... much as I'd like to be able to solve everything for you. So if you'd like to discuss commercial arrangements for help with your outstanding issues, please email sales@plutext.com

Paying for commercial support is a win-win-win:
- win for you/your employer: your issues get attended to; peace of mind
- win for docx4j and other docx4j users: docx4j improves
- win for Plutext: we can invest even more in docx4j

We understand that many/most users of an open source project don't pay, and that some of these contribute in other ways, and we're fine with that. However, there isn't really any excuse for large enterprises users, who have committed to using a project, not to contribute back to it (financially or otherwise). In the case of docx4j, there are a number of large enterprise users (eg government, banking/finance customers) (not to mention ISV's and development houses) who support the project commercially - for which we are very grateful - but many who thus far, have not. Usually its because it is "too hard" to get approval for the expenditure. But all good things take some effort :-)

cheers .. Jason