Pergunta

So I am trying to get an flat file XML version of an OPC document.

I am using OPCPackage from org.apache.poi.openxml4j

In C++ you there is a call that creates flat XML file from this zipped file.

Anyone knows how to do that in Java?

Also any good read related to OPC and Java would be awesome.

Thanks a lot

Cheers

UPDATE: related to the comment i made to only answer...

code

    // imports
    import org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator;
    import org.docx4j.openpackaging.packages.WordprocessingMLPackage;

    // code snippet
    WordprocessingMLPackage wmlPkg = null;
    try 
    {
        wmlPkg = WordprocessingMLPackage.load(inFile);
    } 
    catch (Docx4JException ex) 
    {
        //...
    }

    FlatOpcXmlCreator flatOpcWorker = new FlatOpcXmlCreator((wmlPkg));

    flatOpcWorker.marshal(new FileOutputStream(tmpFlatFile.getAbsolutePath()));

So thats code snippet and it results in compile error:

cannot find symbol symbol: method marshal(java.io.FileOutputStream) location: variable flatOpcWorker of type org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator

Foi útil?

Solução

My project docx4j has a FlatOpcXmlCreator which does this; see the ConvertOutFlatOpenPackage sample

If you want to use it with POI (which uses XML Beans, not JAXB), I guess you could port it. Both projects are ASL, and both do the OPC part based on OpenXML4J.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top