Page 1 of 1

pptx -> html transformation problem

PostPosted: Mon May 03, 2010 10:29 pm
by bonzai
Hey,

I'm having some trouble transforming a .pptx file to html. Here is the code

Code: Select all
      

File pptx = new File("some_path");
      try {
         PresentationMLPackage source = PresentationMLPackage.load(pptx);
         Iterator partIterator = source.getParts().getParts().entrySet().iterator();
         while (partIterator.hasNext()) {

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

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

               System.out.println(XmlUtils.marshaltoString(rl.getShapeTree(), false, true, Context.jcPML,
                     "http://schemas.openxmlformats.org/presentationml/2006/main", "spTree", GroupShape.class));

               SvgExporter.svg(source, rl);
            }
         }
      } catch (Docx4JException e) {
         e.printStackTrace();
      } catch (Exception e) {
         e.printStackTrace();
      }


When I run the code, "SvgExporter.svg(source, rl);" line gives an exception:
Code: Select all
2010-05-03 13:30:03,545 ERROR [org.docx4j.utils.ResourceUtils] - <Couldn't get resource: org/pptx4j/convert/out/svginhtml/pptx2svginhtml.xslt>


I'm using the "docx4j-nightly-20100422.jar" which I downloaded from http://dev.plutext.org/docx4j/ .
Anyone have any idea what the problem is? And better yet, how can I get HTML out of the .pptx file?

Thanks in advance!

Re: pptx -> html transformation problem

PostPosted: Tue May 04, 2010 1:00 am
by jason
That resource is indeed missing from the jar.

I have updated build.xml to ensure it will be in the next nightly I create.

In the meantime, you can get it from http://dev.plutext.org/svn/docx4j/trunk ... svginhtml/

Once you have that, your code should work.

Please note that the svginhtml output is far from complete at present. Right now, it only does text boxes and lines. I was going to implement images next (which should be straightforward), but I haven't had time lately.

So depending on what your slides contain, pptx4j might be too basic for your needs right now. Of course if you are prepared to flesh out the bits you need and contribute them back, I can help you along...

Re: pptx -> html transformation problem

PostPosted: Tue May 04, 2010 10:28 pm
by bonzai
jason wrote:That resource is indeed missing from the jar.

I have updated build.xml to ensure it will be in the next nightly I create.

In the meantime, you can get it from http://dev.plutext.org/svn/docx4j/trunk ... svginhtml/

Once you have that, your code should work.

Please note that the svginhtml output is far from complete at present. Right now, it only does text boxes and lines. I was going to implement images next (which should be straightforward), but I haven't had time lately.

So depending on what your slides contain, pptx4j might be too basic for your needs right now. Of course if you are prepared to flesh out the bits you need and contribute them back, I can help you along...


Hey and thanks for the very quick reply! I added the xslt file to the .jar and it worked :) However, I need to make some changes to the SvgExporter.java, since I need a string back from the function

Code: Select all
svg(PresentationMLPackage presentationMLPackage,
         ResolvedLayout layout)


This is probably not the correct topic to post this, but I'm following the steps from http://dev.plutext.org/trac/docx4j/wiki/DevEnv (for eclipse) but I get the following error when running "mvn install"

Code: Select all
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building docx4j
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [build-helper:add-source {execution: add-source}]
[INFO] Source directory: C:\Users\smonte\workspace\docx4j\src\diffx added.
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 2 resources
[WARNING] POM for 'javax.jms:jms:pom:1.1:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\smonte\workspace\docx4j\src\
test\resources
Downloading: http://dev.plutext.org/svn/docx4j/trunk/docx4j/m2/junit/junit/4.4/j
unit-4.4.jar
[INFO] Unable to find resource 'junit:junit:jar:4.4' in repository docx4j (http:
//dev.plutext.org/svn/docx4j/trunk/docx4j/m2)
Downloading: https://webdavclient4j.svn.sourceforge.net/svnroot/webdavclient4j/t
runk/m2/junit/junit/4.4/junit-4.4.jar
[INFO] Unable to find resource 'junit:junit:jar:4.4' in repository webdavclient4
j (https://webdavclient4j.svn.sourceforge.net/svnroot/webdavclient4j/trunk/m2)
Downloading: http://download.java.net/maven/2//junit/junit/4.4/junit-4.4.jar
[INFO] Unable to find resource 'junit:junit:jar:4.4' in repository maven2-reposi
tory.dev.java.net (http://download.java.net/maven/2/)
Downloading: http://repo1.maven.org/maven2/junit/junit/4.4/junit-4.4.jar

[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 3 source files to C:\Users\smonte\workspace\docx4j\bin
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

error: error reading C:\Users\smonte\.m2\repository\javax\mail\mail\1.4\mail-1.4
.jar; error in opening zip file
error: error reading C:\Users\smonte\.m2\repository\javax\jms\jms\1.1\jms-1.1.ja
r; error in opening zip file
error: error reading C:\Users\smonte\.m2\repository\com\sun\jdmk\jmxtools\1.2.1\
jmxtools-1.2.1.jar; error in opening zip file
error: error reading C:\Users\smonte\.m2\repository\com\sun\jmx\jmxri\1.2.1\jmxr
i-1.2.1.jar; error in opening zip file

[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Tue May 04 13:25:41 EEST 2010
[INFO] Final Memory: 13M/24M
[INFO] ------------------------------------------------------------------------


I'm quite clueless how to fix the prob, any ideas?

Re: pptx -> html transformation problem

PostPosted: Tue May 04, 2010 11:27 pm
by jason
Ignore the error, and build using ant.

See the recent topic in the docx4j forum, which includes the suggested ant command (to address memory issues). iirc this is also documented in the Getting Started guide.