Welcome to OpenXML Developer Sign in | Join | Help

Problem in editing PPTX

Last post 09-08-2008, 4:19 PM by Flip. 6 replies.
Sort Posts: Previous Next
  •  05-13-2008, 12:56 AM 3179

    Problem in editing PPTX

    Hi guys
    I am a little bit confused in my application. I expect a good advice from you geeks.
    My application has a PPTX which acts as a template and I have to create a new PPT everytime by removing the place holders and adding my controls on its place. I am developing the application in java.
    I have tried to develop  it by implementing the openxml4j api, but it is not satisfying my needs.
    So what I am planning is, using java:
    1)   Rename the file to Sample.zip            [Consider Sample.pptx is our template]

    2)   Unzip the Sample.zip

    3)   Edit whichever files to edit.

    4)   Zip the entire directory structure to Sample.zip

    5)   Rename it to Output.pptx

    6)   Convert it to Output.ppt

    Is this aproach a correct one? I have done the steps 1 and 2 successfully. But I am confused on how to complete step 3. How can I edit these xml files using java. From where i can get some help. If I am updating the contents of the powerpoint, in addition to the slide1.xml,slide2.xml... what all xml files I need to edit. Also how can we convert pptx to ppt(step 6)? Is there anyother java api that suits this scenario?
    Please answer



  •  05-14-2008, 5:41 AM 3190 in reply to 3179

    Re: Problem in editing PPTX

    Hi,
                   
    Here are few of the Java packages that provide classes for modifying XML:

    javax.xml.parsers.*
    javax.xml. transform.*
    org.xml.sax.*
    org.w3c.dom.*

    These packages will be available as a part of JDK.
     

    An example for modifying XML using few classes from above packages:
                   
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();           
                         
    File contentTypeXML = new File(extractToFolder + "\\" + "[Content_Types].xml");
               
    Document doc = docBuilder.parse (contentTypeXML);                                
    Element rootElement =  doc.getDocumentElement();                      
    Element override = (Element) doc.createElement("Override");
    int pathLengthToBeIgnored = extractToFolder.length();           
    ----
    ----
                    
     override.setAttribute("PartName", folderForHeader + "/header2.xml");
    override.setAttribute("ContentType","application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml");
       
     rootElement.appendChild(override);

    Mallika

  •  05-14-2008, 6:16 AM 3191 in reply to 3190

    Re: Problem in editing PPTX

    Hi mallika
    But you know we have to edit more than one files. And i hav to update all the contents of the slides. Is their any third party api which deals with this openoffice xml. (other than openxml4j)
  •  05-15-2008, 1:41 AM 3198 in reply to 3191

    Re: Problem in editing PPTX

  •  05-15-2008, 2:02 AM 3199 in reply to 3198

    Re: Problem in editing PPTX

    ya you are correct. there no such api now
    openxml4j doesnt have that much capabilities to handle the above situation
    apache is yet to release
    and docx is for word only.
    one last word...
    is this possible on a windows platform.
    I mean microsoft technology (C#)
  •  05-16-2008, 12:28 AM 3203 in reply to 3199

    Re: Problem in editing PPTX

    Hi,

    In .Net framework(3.0 and 3.5) there is one API called System.IO.Packaging.
    Using C# and that API you can programmataically edit any office 2007 document(docx,xlsx,pptx).
    That means you can edit any xml file also.

    Mallika

  •  09-08-2008, 4:19 PM 3666 in reply to 3203

    Re: Problem in editing PPTX

    Hello,

     i started to work with the openxml4j api. Its no problem to display the package parts, relationships etc. of an presentationml file with that api. But i dont have a chance to edit the xml files inside the package.

    So the api (to time)  is worthless for my jobs.

    Flip
View as RSS news feed in XML