1

I'm looking for a solution capable of producing a result as close to the original as possible, such as this example, which converts .doc rather than .ppt files. It should, ideally, take in a FileInputStream and output a String with the desired html code.

I've come across this question, which posts code very similar to that on the Apache POI website, however it converts to an image and I've been unable to re-purpose it.

Otherwise, there seems to be next to no code out there to do this.

EDIT:

I've tried implementing the Apache Tika solution, however I'm having trouble with the parser. I've seen that several people have had this issue when implementing the library on Android, however I haven't seen anyone suggest a solution.

My code is as follows:

        HSLFSlideShow powerpointDoc = new HSLFSlideShow(inputDocument);
        inputDocument.close();

        List<HSLFSlide> slides = powerpointDoc.getSlides();
        ContentHandler handler = new ToXMLContentHandler();
        AutoDetectParser parser = new AutoDetectParser();
        Metadata metadata = new Metadata();

        for (int i = 0; i <= slides.size(); i++) {
            parser.parse(inputDocument, handler, metadata);
        }

        String result = handler.toString();

Could anyone provide an example of how I might use Apache Tika?

o2tha1
  • 11
  • 5
  • What kind of HTML are you after? Something basic with the text in it? If so, look at Apache Tika, that'll turn PPT or PPTX into XHTML of the text with a div per slide – Gagravarr May 30 '18 at 05:54
  • @Gagravarr I'm looking for HTML capable of displaying the document as close to the original as possible. Am I right in understanding that Apache Tika would handle the text, but not the formatting? – o2tha1 May 30 '18 at 08:19
  • You're going to need to write a lot of code or pay a lot of money then.... – Gagravarr May 30 '18 at 10:19
  • Please see my edit – o2tha1 May 30 '18 at 12:32
  • If this wasn't tagged with Android, I would use a [Graphics2d to html renderer](https://github.com/rigd-loxia/gwtx-g2d). If I would have that task, I would provide my own Graphics2d context and extend the Draw* classes. This works of course only for static content, animations would have to be applied somehow from the outside. I know someone who provides this as part of a platform and it took him around 1 year (with a team) to get good results. – kiwiwings May 30 '18 at 14:19

0 Answers0