You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Sarfaraz Husain <sa...@gmail.com> on 2015/07/29 13:50:44 UTC
Word to OOXML Conversion using Apache POI
Hi Guys,
Is there a way to convert the Word Document to OOXML using Apache POI and
save this XML?
Basically I have to convert the Document to OOXML and then extract the
important data points and images from it. Data in the Document is wrapped
around Content Controls. I dont want to loop through it and have been asked
to use XSLT to extract data points. Therefore I am looking for a way to
save Word to XML with all information in it like WordML, images and all
relation xml data, basically a full XML.
Please suggest the pointer or any java code, test case would be really
helpful.
Thanks in advance!
Regards,
Sarfaraz
Re: Word to OOXML Conversion using Apache POI
Posted by Angelo zerr <an...@gmail.com>.
Hi
We have developped several converter docx->pdf, docx->xhtml based on POI
inside XDocReport.
You can see docx->xhtml at
https://github.com/opensagres/xdocreport/tree/master/thirdparties-extension/org.apache.poi.xwpf.converter.xhtml
and a little doc at
https://code.google.com/p/xdocreport/wiki/XWPFConverterXHTML
Developping a converter is a very hard task, our converters are not perfect.
Good luck!
Regard's Angelo
2015-07-30 3:18 GMT+02:00 Sarfaraz Husain <sa...@gmail.com>:
> Thanks a lot.
> Any working code example will really help me.
>
> Thanks,
> Sarfaraz
>
> On Wednesday, July 29, 2015, Nick Burch <ap...@gagravarr.org> wrote:
>
> > On Wed, 29 Jul 2015, David kerber wrote:
> >
> >> Unzip it, and combine the resulting .xml files into a single file?
> >>
> >
> > You don't even need to unzip it as such, the OPC code in POI will let you
> > navigate the relationships and fetch out the content of the individual
> xml
> > files + image files.
> >
> > Nick
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> >
> >
>
Re: Word to OOXML Conversion using Apache POI
Posted by Sarfaraz Husain <sa...@gmail.com>.
Thanks a lot.
Any working code example will really help me.
Thanks,
Sarfaraz
On Wednesday, July 29, 2015, Nick Burch <ap...@gagravarr.org> wrote:
> On Wed, 29 Jul 2015, David kerber wrote:
>
>> Unzip it, and combine the resulting .xml files into a single file?
>>
>
> You don't even need to unzip it as such, the OPC code in POI will let you
> navigate the relationships and fetch out the content of the individual xml
> files + image files.
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: Word to OOXML Conversion using Apache POI
Posted by Nick Burch <ap...@gagravarr.org>.
On Wed, 29 Jul 2015, David kerber wrote:
> Unzip it, and combine the resulting .xml files into a single file?
You don't even need to unzip it as such, the OPC code in POI will let you
navigate the relationships and fetch out the content of the individual xml
files + image files.
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Word to OOXML Conversion using Apache POI
Posted by David kerber <dc...@verizon.net>.
On 7/29/2015 10:05 AM, Sarfaraz Husain wrote:
> Thanks Nick for your prompt reply.
>
> But how I can do it in Java code, I mean convert .docx to XML? I know If I
> renamed .docx to .zip I can see everything XMLs, images, styles etc.
>
> But suppose if I am getting .docx in my java class and then I want to
> convert it into XML, how that can be achieved?
Unzip it, and combine the resulting .xml files into a single file? As
has already been pointed out, a .docx file is just a group of .xml files
combined into a .zip.
>
> Thanks,
> Sarfaraz
>
> On Wed, Jul 29, 2015 at 8:17 PM, Nick Burch <ap...@gagravarr.org> wrote:
>
>> On Wed, 29 Jul 2015, Sarfaraz Husain wrote:
>>
>>> I am looking a way to convert Word .docx file to XML with all information
>>> in that XML like wordML, images and other relation xml etc. all in one XML
>>> file.
>>>
>>
>> .docx files are already XML, it's a zip file with several different xml
>> files in there (content, styles etc), all in the OOXML-defined structures
>> and format
>>
>>
>> Nick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Word to OOXML Conversion using Apache POI
Posted by Sarfaraz Husain <sa...@gmail.com>.
Thanks Nick for your prompt reply.
But how I can do it in Java code, I mean convert .docx to XML? I know If I
renamed .docx to .zip I can see everything XMLs, images, styles etc.
But suppose if I am getting .docx in my java class and then I want to
convert it into XML, how that can be achieved?
Thanks,
Sarfaraz
On Wed, Jul 29, 2015 at 8:17 PM, Nick Burch <ap...@gagravarr.org> wrote:
> On Wed, 29 Jul 2015, Sarfaraz Husain wrote:
>
>> I am looking a way to convert Word .docx file to XML with all information
>> in that XML like wordML, images and other relation xml etc. all in one XML
>> file.
>>
>
> .docx files are already XML, it's a zip file with several different xml
> files in there (content, styles etc), all in the OOXML-defined structures
> and format
>
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: Word to OOXML Conversion using Apache POI
Posted by Nick Burch <ap...@gagravarr.org>.
On Wed, 29 Jul 2015, Sarfaraz Husain wrote:
> I am looking a way to convert Word .docx file to XML with all information
> in that XML like wordML, images and other relation xml etc. all in one XML
> file.
.docx files are already XML, it's a zip file with several different xml
files in there (content, styles etc), all in the OOXML-defined structures
and format
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Word to OOXML Conversion using Apache POI
Posted by Sarfaraz Husain <sa...@gmail.com>.
Hi,
I think I have not summarized it correctly. Sorry for that.
I am looking a way to convert Word .docx file to XML with all information
in that XML like wordML, images and other relation xml etc. all in one XML
file.
Thanks,
Sarfaraz
On Wed, Jul 29, 2015 at 7:57 PM, Nick Burch <ap...@gagravarr.org> wrote:
> On Wed, 29 Jul 2015, Sarfaraz Husain wrote:
>
>> Is there a way to convert the Word Document to OOXML using Apache POI and
>> save this XML?
>>
>
> As in to convert a Word .doc file into a Word .docx file? (.docx files are
> OOXML-based)
>
> If so, sadly the answer is no using Apache POI. It would be nice to have a
> converter like that, but thus far no-one has volunteered to put in the time
> to write one. If someone wanted to contribute one, the Word to FO / HTML
> converters would probably be a good place to start.
>
> For now, using something like OpenOffice (probably via jodconverter) is
> likely to be your best bet
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: Word to OOXML Conversion using Apache POI
Posted by Nick Burch <ap...@gagravarr.org>.
On Wed, 29 Jul 2015, Sarfaraz Husain wrote:
> Is there a way to convert the Word Document to OOXML using Apache POI
> and save this XML?
As in to convert a Word .doc file into a Word .docx file? (.docx files are
OOXML-based)
If so, sadly the answer is no using Apache POI. It would be nice to have a
converter like that, but thus far no-one has volunteered to put in the
time to write one. If someone wanted to contribute one, the Word to FO /
HTML converters would probably be a good place to start.
For now, using something like OpenOffice (probably via jodconverter) is
likely to be your best bet
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Word to OOXML Conversion using Apache POI
Posted by Harry Zhou <su...@gmail.com>.
Has anyone considered http://documents4j.com?
On Wednesday, July 29, 2015, Sarfaraz Husain <sa...@gmail.com>
wrote:
> Hi Guys,
>
> Is there a way to convert the Word Document to OOXML using Apache POI and
> save this XML?
>
> Basically I have to convert the Document to OOXML and then extract the
> important data points and images from it. Data in the Document is wrapped
> around Content Controls. I dont want to loop through it and have been asked
> to use XSLT to extract data points. Therefore I am looking for a way to
> save Word to XML with all information in it like WordML, images and all
> relation xml data, basically a full XML.
>
> Please suggest the pointer or any java code, test case would be really
> helpful.
>
> Thanks in advance!
>
> Regards,
> Sarfaraz
>
--
Best Regards
Harry Zhou