Page 1 of 1

Adding content into existing shape via XHTMLtoPPTX

PostPosted: Thu Nov 06, 2014 10:18 am
by pengppp11
Hi

I'm now trying to convert well-formed html into pptx, and I think "XHTMLtoPPTX" as a good start point. I used the method "convertSingleSlide" to convert html fragments. As a result, the contents converted into the pptx are always in a new created shape according to "PARAGRAPH_SHAPE" in the class "XHTMLtoPPTX". but what I want is to convert those html into the existing shape like the shape for title or content in the title and content slide.

Can someone give me some suggestions ? Thanks a lot

Re: Adding content into existing shape via XHTMLtoPPTX

PostPosted: Tue Nov 11, 2014 9:11 am
by pengppp11
Hello

I'm trying firstly to get a certain existing shape node via XPATH, e.g. "//p:sp[p:nvSpPr/p:nvPr/p:ph/@type='title']" to get the shape node for title, then I want to get corresponding shape object via the following code :

List<Object> nodeLists = slidePart.getJAXBNodesViaXPath(xpath, false);

for(Object o : nodeLists){
//System.out.println(nodeLists.size());
Shape shape =(Shape) ((JAXBElement) o).getValue();
}

but I got the Excepition : "org.pptx4j.pml.Shape cannot be cast to javax.xml.bind.JAXBElement", how can I solve this problem and to get the shape object. :? or is there another way to get a certain existing shape ? I appreciate someone could help me. :)

Re: Adding content into existing shape via XHTMLtoPPTX

PostPosted: Tue Nov 11, 2014 12:55 pm
by jason
Looks like your Object o is already a Shape object, so ((JAXBElement) o) is causing that error.

Try:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
Shape shape =(Shape) o;
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4