Welcome to OpenXML Developer Sign in | Join | Help

Document management utility written in Java

Submitted by: Sanjay Kumar Madhva, Srinidhi H. S., Pujari Yerriswamy (Sonata Software Ltd)

In a prior article on OpenXmlDeveloper.org, we demonstrated that it is possible to create a word document by creating a few XML files and assembling them into a package. That program will give you a feel for what goes into the document package.

In this article, we move on to some common tasks for working with Open XML Format documents. The utility below (with Java source code) provides a variety of useful functionality for creating and editing Open XML Format documents:

  • Create a package (OpenXML Document).
  • List out the parts contained in the Document.
  • Delete file (part) from the package.
  • Extract a file from the package.
  • Extract all the files from the package.
  • Add a new file into the package.

The above functionality will be very useful when you have to edit the document, and it is also a good example of various techniques for opening and working with documents stored in the Open XML Formats.

 
JAVA Document Utility
/*
 * Created on Mar 22, 2006
 * @author Srinidhi.H S / Sanjay.Kumar.M / Pujari Yerriswamy
 *         Sonata Software Limited.
 *
 */
//package com.zip;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.*;

public class OpenXMLDocumentFile
{

    private final static String TEMP_SUFFIX = "temp";

    private String srcZipFileName = "";

    //Deletes Files from the Zip
    // SourceZip   = Provide Source zip file
    // SplitString = Files to delete, Each file separated by a Split Character
    // SplitBy     = Split Character
    public static void DeleteFiles(String SourceZip, 
                                      String SplitString, 
                               String SplitBy)
    {
        String[] temp = null;

        temp = SplitString.split(SplitBy);

        List deleteFileList = new ArrayList();

        for (int x = 0; x < temp.length; x++)
        {
            deleteFileList.add(temp[x]);
        }
        OpenXMLDocumentFile delFileObj = new OpenXMLDocumentFile();

        //Zip file name
        delFileObj.setSrcZipFileName(SourceZip);

        //invoke the method to delete the files in the ZIP
        delFileObj.deleteFileInZip(deleteFileList);
    }

    // Deletes Files from the Zip
    // SourceZip   = Provide Source zip file
    // SplitString = Files to delete, Each file supprated by a Split Character
    // SplitBy     = Split Character
    public static void DeleteFiles(String SourceZip, String DeleteFileName)
    {
        List deleteFileList = new ArrayList();

        deleteFileList.add(DeleteFileName);

        OpenXMLDocumentFile delFileObj = new OpenXMLDocumentFile();

        //Zip file name
        delFileObj.setSrcZipFileName(SourceZip);

        //invoke the method to delete the files in the ZIP
        delFileObj.deleteFileInZip(deleteFileList);
    }

    public void deleteFileInZip(List fileNames){
        try{
            File sourceZipFile = new File(getSrcZipFileName());
    
            //Open the ZIP file for reading
            ZipFile zipFile = new ZipFile(sourceZipFile,ZipFile.OPEN_READ);
    
            //Get the entries
            Enumeration enum = zipFile.entries();
            
            List newZipEntries = new ArrayList();
            
            while(enum.hasMoreElements()) 
            {
                ZipEntry zipEntry = (ZipEntry)enum.nextElement();
                String currName = zipEntry.getName();
                //Skip the files to be deleted
                if(!fileNames.contains(currName)){
                    newZipEntries.add(zipEntry);
                }
            }
            
            createZipFileToDelete(newZipEntries,zipFile);
            zipFile.close();
            //Delete the sourceZipFile
            sourceZipFile.delete();
            
            // rename tempZipFile and delete it
            File tempFile = new File(getSrcZipFileName()+TEMP_SUFFIX);
            tempFile.renameTo(sourceZipFile);
            tempFile.delete();
        }
        catch(IOException ioe){
            System.out.println("IOException occured====="+ioe);
            ioe.printStackTrace();
        }
    }

    private void createZipFileToDelete(List zipEntries, ZipFile zipFile) 
throws IOException
    {
        ZipOutputStream zipOStream = new ZipOutputStream
(new FileOutputStream(getSrcZipFileName() + TEMP_SUFFIX));

        zipOStream.setLevel(Deflater.BEST_COMPRESSION);
        InputStream inStream;
        for (int i = 0; i < zipEntries.size(); i++)
        {
            ZipEntry tempZipEntry = (ZipEntry)zipEntries.get(i);

            zipOStream.putNextEntry(new ZipEntry(tempZipEntry.getName()));
            inStream = zipFile.getInputStream(tempZipEntry);

            int ch = 0;
            while ((ch = inStream.read()) != -1)
            {
                zipOStream.write(ch);
            }
            zipOStream.closeEntry();
            inStream.close();
        }
        zipOStream.flush();
        zipOStream.close();
    }

    /**
     * @return
     */
    public String getSrcZipFileName()
    {
        return srcZipFileName;
    }

    /**
     * @param string
     */
    public void setSrcZipFileName(String string)
    {
        srcZipFileName = string;
    }

    // Create zipfile 
    // SourceZip   = Provide Source zip file
    // SplitString = Files to delete, Each file supprated by a Split Character
    // SplitBy     = Split Character
    public static void Create(String zipFileName, String SplitString, String SplitBy)
    {
        String[] temp = null;

        temp = SplitString.split(SplitBy);

        List AddFileList = new ArrayList();

        for (int x = 0; x < temp.length; x++)
        {
            AddFileList.add(temp[x]);
        }
        Create(zipFileName, AddFileList);
    }

    public static void Create(String zipFileName, List ToCompressFiles)
    {
        try
        {
            FileInputStream inStream;

            FileOutputStream outStream = new FileOutputStream(zipFileName);

            ZipOutputStream zipOStream = new ZipOutputStream(outStream);

            zipOStream.setLevel(Deflater.BEST_COMPRESSION);

            for (int loop = 0; loop < ToCompressFiles.size(); loop++)
            {
                inStream = new FileInputStream((String)ToCompressFiles.get(loop));
                zipOStream.putNextEntry
(new ZipEntry((String)ToCompressFiles.get(loop)));

                int i = 0;
                while ((i = inStream.read()) != -1)
                {
                    zipOStream.write(i);
                }

                zipOStream.closeEntry();
                inStream.close();
            }
            zipOStream.flush();
            zipOStream.close();
        }
        catch (IllegalArgumentException iae)
        {
            iae.printStackTrace();
        }
        catch (FileNotFoundException fe)
        {
            System.out.println("File not found====" + fe);
        }
        catch (IOException ioe)
        {
            System.out.println("IOException====" + ioe);
            ioe.printStackTrace();
        }
    }

    // Add the file into the zip
    // SourceZip   = Provide Source zip file
    // addFileName = file to be added into the zip.
    public static void Add(String SourceZip, String addFileName)
    {
        List addFileList = new ArrayList();

        addFileList.add(addFileName);

        OpenXMLDocumentFile addFileObj = new OpenXMLDocumentFile();

        //invoke the method to Add the files to ZIP
        addFileObj.Add(SourceZip, addFileList);
    }

    // Add the file into the zip
    // SourceZip   = Provide Source zip file
    // SplitString = Files to add, Each file supprated by a Split Character
    // SplitBy     = Split Character
    public static void Add(String zipFileName, String SplitString, String SplitBy)
    {
        String[] temp = null;

        temp = SplitString.split(SplitBy);

        List AddFileList = new ArrayList();

        for (int x = 0; x < temp.length; x++)
        {
            AddFileList.add(temp[x]);
        }
        OpenXMLDocumentFile addFileObj = new OpenXMLDocumentFile();

        //invoke the method to Add the files to ZIP
        addFileObj.Add(zipFileName, AddFileList);
    }

    public void Add(String nameOfZip, List fileNamesToAdd)
    {
        File tempZip = null;
        
        try
        {
            tempZip = File.createTempFile(nameOfZip + TEMP_SUFFIX, null); // 
        }
        catch (IOException e)
        {
            System.err.println("Unable to create intermediate file.");
        }

        ZipFile zip = null;
        try
        {
            zip = new ZipFile(nameOfZip);
        }
        catch (IOException e)
        {
            System.err.println("Unable to access original file.");
        }

        // Only rename file at end on success
        boolean success = false;
        try
        {
            ZipOutputStream newZip = new ZipOutputStream(new FileOutputStream(tempZip));
            try
            {
                //Copy files
                copyFiles(zip, newZip);
                //Add new files
                addNewFilesToZip(fileNamesToAdd, newZip);
                success = true;
            }
            catch (IOException ex)
            {
                System.err.println("Operation aborted due to : " + ex);
            }
            finally
            {
                try
                {
                    newZip.close();
                }
                catch (IOException ignored) { }
            }
        }
        catch (IOException ex)
        {
            System.err.println("Can't access new file");
        }
        finally
        {
            try
            {
                zip.close();
            }
            catch (IOException ignored) { }
            if (!success)
            {
                tempZip.delete();
            }
        }
        if (success)
        {
            File origFile = new File(nameOfZip);
            origFile.delete();
            tempZip.renameTo(origFile);
        }
    }

    private void addNewFilesToZip(List fileNamesToAdd, ZipOutputStream newZip) 
throws FileNotFoundException, IOException
    {
        byte buffer[] = new byte[1024];
        int bytesRead;
        if (fileNamesToAdd != null && fileNamesToAdd.size() > 0)
        {
            FileInputStream fis = null;
            for (int i = 0; i < fileNamesToAdd.size(); i++)
            {
                try
                {
                    fis = new FileInputStream((String)fileNamesToAdd.get(i));
                    ZipEntry entry = new ZipEntry((String)fileNamesToAdd.get(i));
                    newZip.putNextEntry(entry);
                    while ((bytesRead = fis.read(buffer)) != -1)
                    {
                        newZip.write(buffer, 0, bytesRead);
                    }
                }
                catch (ZipException e)
                {
                    String msg = (String)e.getMessage();
                    if (msg.indexOf("duplicate entry:") != -1)
                    {
                        System.err.println(msg);
                        continue;
                    }
                }
                finally
                {
                    if (fis != null)
                    {
                        fis.close();
                    }
                }
            }
        }
    }

    private void copyFiles(ZipFile zip, ZipOutputStream newZip) throws IOException
    {
        byte buffer[] = new byte[1024];
        int bytesRead;
        // Add back the original files
        Enumeration entries = zip.entries();
        while (entries.hasMoreElements())
        {
            // Prompt for copy
            ZipEntry entry = (ZipEntry)entries.nextElement();
            String name = entry.getName();
            InputStream is = zip.getInputStream(entry);
            newZip.putNextEntry(new ZipEntry(name));
            while ((bytesRead = is.read(buffer)) != -1)
            {
                newZip.write(buffer, 0, bytesRead);
            }
        }
    }

    public static void ExtractAll(String zipFileName, String ToExtractFile)
    {
        try
        {
            File sourceZipFile = new File(zipFileName);
            File destDirectory = new File(ToExtractFile);

            //Open the ZIP file for reading
            ZipFile zipFile = new ZipFile(sourceZipFile,ZipFile.OPEN_READ);

            //Get the entries
            Enumeration enum = zipFile.entries();

            while(enum.hasMoreElements())
            {
                ZipEntry zipEntry = (ZipEntry)enum.nextElement();

                String currName = zipEntry.getName();

                File destFile = new File(destDirectory,currName);

                // grab file's parent directory structure
                File destinationParent = destFile.getParentFile();

                // create the parent directory structure if needed
                destinationParent.mkdirs();

                if(!zipEntry.isDirectory())
                {
                    BufferedInputStream is = new
 BufferedInputStream(zipFile.getInputStream(zipEntry));
                    int currentByte;

                    // write the current file to disk
                    FileOutputStream fos = new FileOutputStream(destFile);
                    BufferedOutputStream dest = new BufferedOutputStream(fos);

                    // read and write until last byte is encountered
                    while ((currentByte = is.read()) != -1)
                    {
                        dest.write(currentByte);
                    }
                    dest.flush();
                    dest.close();
                    is.close();
                }
            }
        }
        catch(IOException ioe)
        {
            System.out.println("IOException occured====="+ioe);
            ioe.printStackTrace();
        }
    }

    // Display the list of files present int the document
    public static void DisplayFiles(String zipFileName)
    {
        String[] TempString = ListFiles(zipFileName);
        for (int x = 0; x < TempString.length; x++)
        {
            System.out.println(TempString[x]);
        }
    }

    // return a list of files in the zip as an array of strings
    public static String[] ListFiles(String zipFileName)
    {
        List _tempString = null;
        _tempString = FilesList(zipFileName);
        String[] retarray = new String[_tempString.size()];
        for (int i = 0; i < _tempString.size(); i++)
        {
            retarray[i] = (String)_tempString.get(i);
        }
        return retarray;
    }

    // return a list of files in the zip as an List
    public static List FilesList(String zipFileName)
    {
        try
        {
            List _tempString = new ArrayList();

            File sourceZipFile = new File(zipFileName);

            //Open the ZIP file for reading
            ZipFile zipFile = new ZipFile(sourceZipFile,ZipFile.OPEN_READ);

            //Get the entries
            Enumeration enum = zipFile.entries();

            while(enum.hasMoreElements())
            {
                ZipEntry zipEntry = (ZipEntry)enum.nextElement();

                String currName = zipEntry.getName();

                _tempString.add(currName);
            }
            
            return    _tempString;
        }
        catch(IOException ioe)
        {
            System.out.println("IOException occured====="+ioe);
            ioe.printStackTrace();
            return    null;
        }
    }

    // Extract one file out of the zip file
    // zipFileName            = 
    // ToExtractFile        = The file that needs to be extracted.
    // FolderToExtractIn    = Folder into which the extract file as to be placed
    public static void ExtractFile(String zipFileName, String ToExtractFile, 
String FolderToExtractIn)
    {
        try
        {
            File sourceZipFile = new File(zipFileName);
            File destDirectory = new File(FolderToExtractIn);

            //Open the ZIP file for reading
            ZipFile zipFile = new ZipFile(sourceZipFile,ZipFile.OPEN_READ);

            //Get the entries
            Enumeration enum = zipFile.entries();

            while(enum.hasMoreElements())
            {
                ZipEntry zipEntry = (ZipEntry)enum.nextElement();

                String currName = zipEntry.getName();
                if (currName.equals(ToExtractFile)) 
                {
                    File destFile = new File(destDirectory,currName);

                    // grab file's parent directory structure
                    File destinationParent = destFile.getParentFile();

                    // create the parent directory structure if needed
                    destinationParent.mkdirs();

                    if(!zipEntry.isDirectory())
                    {
                        BufferedInputStream is = new 
BufferedInputStream(zipFile.getInputStream(zipEntry));
                        int currentByte;

                        // write the current file to disk
                        FileOutputStream fos = new FileOutputStream(destFile);
                        BufferedOutputStream dest = new BufferedOutputStream(fos);
    
                        // read and write until last byte is encountered
                        while ((currentByte = is.read()) != -1)
                        {
                            dest.write(currentByte);
                        }
                          dest.flush();
                          dest.close();
                          is.close();
                    }
                }
            }
        }
        catch(IOException ioe)
        {
            System.out.println("IOException occured====="+ioe);
            ioe.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        if (args.length > 0)
        {
            if (args[0].equals("-L") || args[0].equals("-l"))
            {
                DisplayFiles(args[1]);
            }
            else if (args[0].equals("-D") || args[0].equals("-d"))
            {
                if (args.length == 4)
                {
                    DeleteFiles(args[1], args[2], args[3]);
                }
                else if (args.length == 3)
                {
                    DeleteFiles(args[1], args[2]);
                }
            }
            else if (args[0].equals("-U") || args[0].equals("-u"))
            {
                ExtractAll(args[1], args[2]);
            }
            else if (args[0].equals("-E") || args[0].equals("-e"))
            {
                ExtractFile(args[1], args[2], args[3]);
            }
            else if (args[0].equals("-c") || args[0].equals("-C"))
            {
                Create(args[1], args[2], args[3]);
            }
            else if (args[0].equals("-A") || args[0].equals("-a"))
            {
                if (args.length == 4)
                {
                    Add(args[1], args[2], args[3]);
                }
                else if (args.length == 3)
                {
                    Add(args[1], args[2]);
                }
            }
            else
            {
                DisplayUsage();
            }
        }
        else
        {
            DisplayUsage();
        }
    }


    // This will be used by the main application block to display how to use this application
    private static void DisplayUsage()
    {
        System.out.println("Usage ----------------------------------------------------");
        System.out.println("");
        System.out.println("To List file in the Document");
        System.out.println("");
        System.out.println("    Java OpenXMLDocumentFile -L ");
        System.out.println("");
        System.out.println("To Delete file from the Document");
        System.out.println("    Option 1 :");
        System.out.println("");
        System.out.println("    Java OpenXMLDocumentFile -D  ");
        System.out.println("    Option 2 :");
        System.out.println("");
        System.out.println("    Java OpenXMLDocumentFile -D  \" ");
        System.out.println("");
        System.out.println("Extract one File From Zip");
        System.out.println("");
        System.out.println("    Java OpenXMLDocumentFile -E   ");
        System.out.println("");
        System.out.println("To Add file from the Document");
        System.out.println("    Option 1 :");
        System.out.println("");
        System.out.println("    Java OpenXMLDocumentFile -a  ");
        System.out.println("    Option 2 :");
        System.out.println("");
        System.out.println("    Java OpenXMLDocumentFile -a  \"

Published Sunday, March 26, 2006 8:37 PM by dmahugh
Filed Under: , ,

Comments

 

Stephane Rodriguez said:


I strongly recommend to either edit this post or delete it altogether. It is very misleading.

You said things like "Delete file (part) from the package."

It could not be further from the truth, a part does not equal a file. A part is more than that.

Besides this, the implementation is poor performance wise. There does not seem to be a valid reason to totally unzip a zip file only to be able to delete a file entry in it. Or to replicate all the files from a zip file into a new one only to add a file entry in it.

In addition to this, deleting or adding parts is a rather different job than deleting or adding file entries. This System.IO.Packaging library is already far too low-level as it requires you to play with the guts (see Kevin's code snippets), but this one really makes the cake.

My 2 cents.
March 27, 2006 3:34 AM
 

dmahugh said:

Stephane,

I'll let the authors speak for themselves on some of the details, but I don't feel this post is misleading.  Yes, it's very low-level, but that's the nature of the beast: it's an example of working with Open XML Formats without the benefit of any APIs or tools from any vendor.  If that's the goal, then the simplicity of things like unzipping the whole package is probably more important than optimizing the runtime performance at this point.

And yes, a part is conceptually more than just a file, but again if ouy goal is education then this is a logical first step, getting at the files within the package.  Extending this code to manage the relationships and content types that make a file a true "part" is a great idea -- feel free to submit code for that any time. :-)

- Doug
March 27, 2006 9:00 PM
 

Stephane Rodriguez said:


Thanks for your answer. I'll say it differently,

If the point of this website is to gather a community around Open XML and open packaging conventions, then this article is irrelevant.

If you'd like to easily corrupt files from an OPC standpoint, files that won't open in Word/Excel/Powerpoint 2007, then this is exactly the code you are looking for.

For the record, there is a disconnect between zip entries and parts. If you fail to educate developers from the start, and insist saying it's just  ZIP, then how are they supposed to understand?

You said "Extending this code to manage the relationships and content types that make a file a true part is a great idea". Any code snippet dealing with the open packaging conventions must explicitely work with parts and their relationships, using appropriate code. It's not a "suitable extension", it's what the whole thing is about.

What to do? a low-level library *must* replicate the features of System.IO.Packaging, no matter which programming language it is written in. It does not have to expose the same object model, but it has to expose parts and relationships in a way that a developer can manipulate them without causing corruption of any sort. A library at a higher level hides parts and relationships so that a developer can directly manipulate "managed content". An example of higher-level library is the COM library of Word/Excel/Powerpoint.

My 2 cents.
March 28, 2006 12:36 AM
 

SanjayKumarM said:

The main idea of writing this block of code was to create code for creating and editing of packages using Java.  This might not be best approach or mechanism to do this, but idea was to showcase implementation of OpenXML using other technologies.

By saying Delete file I did not mean remove part, for part may be referenced in other XML files.

Delete feature was provided because I felt that there was a need, for it would provided a mechanism of removing file from the ZIP.

For Example, if in the package there was an image of type BMP that needed to be removed and replaced by an Image of type PNG there by reducing the size of the document. Utility provided a way to delete the BMP from the ZIP. But code had to be written to remove the reference of the BMP (<Default Extension="bmp" ContentType="image/bitmap" /> ) from the “[content-type.xml]”, and also have to remove the referenced BMP file from relationship file “document.xml.rels.” (<Relationship Id="rId4" Type="http://schemas.microsoft.com/office/2006/relationships/image" Target="media/image1.bmp"/>)

Please feel free to send your comments or any other alternative mechanism thought of.

Sanjay Kumar M
March 28, 2006 12:45 AM
 

Stephane Rodriguez said:


Hi Sanjay,

"The main idea of writing this block of code was to create code for creating and editing of packages using Java."

No that's not what the code above does. The code above creates and edits zip files. It has nothing to do with packages, and nothing to do with parts. It ignores OPC. Sorry, I don't intend to be harsh, I am only using the correct terminology.

March 28, 2006 12:56 AM
 

SanjayKumarM said:

Hi Stephane,

   No hard feeling.  

    Correct me if I am wrong. A OpenXML Package is a Zip archive that contains all the relationship items and parts of the Office Open XML documents.

Thanks
Sanjay
March 28, 2006 7:41 AM
 

Stephane Rodriguez said:


We are getting closer with this definition.

An OpenXML package is a specialization of OPC package. The OPC package is defined in the documentation (OPC 0.85). The specialization is defined by the OpenXML schemas (TC45).

In essence, an OPC package contains logical parts and relationships. The physical model of an OPC package is a zip file with strict rules it adheres to. You simply cannot add or delete a zip entry as freely as you'd like to.
March 28, 2006 8:46 AM
 

SanjayKumarM said:


Hi Stephan,

  I do agree that the files cannot be deleted with out changing the reference in the XML file. We are building by pieces, Please wait for the next article that will combine the above code with the XML modification code to remove a BMP and replace it with PNG.

In the next article we will use the OpenXMLDocumentFile class of the current article as is and show how we can extract the "[content-type.xml]" and "document.xml.rels.” and the BMP files from the zipped archive, and modify the XML content so that it will not use the BMP file but to point to the new PNG file converted from the BMP file. Delete the BMP file present in the Zip Archive and replace it with the PNG file to reduce the size of the Document.

Regards
Sanjay
March 28, 2006 10:38 PM
 

seweso said:

I am 99% certain they just renamed a java zip-utility to OpenXMLDocumentFile.

Great work!
March 30, 2006 7:16 AM
 

orcmid said:

I'm going to be a little cranky here.

First, the ECMA draft for Office Open XML neither identifies nor refers to any OPC specification.  So there's complaining about facts not in evidence here.

Secondly, where did I miss public availability of OPC 0.85?  My copy says 0.80 of December 2005 and nothing has changed at the Specification and License Downloads page (http://www.microsoft.com/whdc/xps/downloads.mspx).  I see that Andy Simonds says XPS 0.85 will be available real-soon-now but that's all I can find.

If I were the umpire I'd declare an illegal procedure about here. But I'm not so I won't.

I agree that there should be better understanding of the levels of OPC abstraction and also what the invariants are for the Zip archive.  (see the Forum thread at http://openxmldeveloper.org/forums/thread/112.aspx).  Meanwhile, it seems to me that Sanjay is doing fine with the information that's publicly available and with making a serious experimental and empirical contribution.

OK, I came over here to find out what the question about parts was that Doug mentioned.  Here's my trial response:  It can be a part if it (1) has a content type, (2) can be a named item in the package, (3) can be the target and source of relationship components, and can be used that way by whatever document the package is carrying.  

It would seem to me that (3) depends on the need to be able to reference the part from other parts.  There must be a way that works.

That is, if there are explicit relationships that target the part, one can't monkey with the relationship without being able to modify the source part as well.  If there are only implicit relationships to a target, I guess the rules for the type of relationship will determine what is acceptable.  I'm looking at section 9.2 of the ECMA TC45 base document for this.

How's that sound?
March 30, 2006 5:30 PM
 

orcmid said:

The OPC 0.85 Specification is now available.  I still recommend working with the OOX Package as it is specified in the ECMA draft, for now (http://openxmldeveloper.org/forums/permalink/41/132/ShowThread.aspx#132).
March 31, 2006 9:34 PM
 

SanjayKumarM said:

Hi Stephane

   As promissed the artical where I have used the packaging code and implemented "Open XML Document Image Conversion"
April 13, 2006 12:35 AM
 

broshni said:

hi folks
i m new to openxml
and i m getting through it recently
i hav a docx file which I am trying to parse into an html file.
i hav some images in the docx fiel itself. i m using java nd xslt to serve the purpose. i solved somehow the issues with text but still struggling with image part.
the image part is linked like
<pic:blipFill>
 <a:blip r:embed="rId4" />
</pic:blipFill>
where rId4 is being stored in another xml file-
/word/_rels/document.xml.rels
i m trying to iterate though this xml file using java and get the target of rId4 relaltionship.
and i come to know that all the images are stored in media folder as image1.jpeg, image2.jpeg etc
please do help me out.
any comments would be highly appreciative
with regards?
broshni
September 1, 2008 10:43 AM
Anonymous comments are disabled