简体   繁体   中英

How to display ppt file in Android views using Docx4j?

I am working on Android and using docx4j to view the docx,pptx and xlsx files into my application.

I am unable to view the ppt files. I am getting compile time error at SvgExporter class. which is not there in docx4j library.

How can I get the SvgExporter class library and build my application and get the Svghtml to load on webview for ppt files? My code is as follows:

    String inputfilepath = System.getProperty("user.dir") + "/sample-docs/pptx/pptx-basic.xml";

    // Where to save images
    SvgExporter.setImageDirPath(System.getProperty("user.dir") + "/sample-docs/pptx/");

    PresentationMLPackage presentationMLPackage = 
        (PresentationMLPackage)PresentationMLPackage.load(new java.io.File(inputfilepath));     

    // TODO - render slides in document order!
    Iterator partIterator = presentationMLPackage.getParts().getParts().entrySet().iterator();
    while (partIterator.hasNext()) {

        Map.Entry pairs = (Map.Entry)partIterator.next();

        Part p = (Part)pairs.getValue();
        if (p instanceof SlidePart) {

            System.out.println(
                    SvgExporter.svg(presentationMLPackage, (SlidePart)p)
                    );
        }
    }

    // NB: file suffix must end with .xhtml in order to see the SVG in a browser
}   

SvgExporter uses XSLT and Xalan extension functions to do its thing.

IIRC, there were problems getting Xalan working on Android (you should verify this yourself).

If that remains the case, then you'll need to write a version of SvgExporter which does the traversal in Java code, as opposed to relying on Xalan to do this.

That should be quite feasible; there are "NonXSLT" examples in the docx4j code base.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM