com.adobe.idml.samples
Class ReplaceImages

java.lang.Object
  extended by com.adobe.idml.samples.ReplaceImages

public class ReplaceImages
extends java.lang.Object

This class contains tools that can be used to replace images in an IDML Package. These tools can be used to replace either linked or embedded images. However, all image replacements will be linked. This tool cannot replace an image with an embedded image.


Constructor Summary
ReplaceImages(java.lang.String xslDirPath, java.lang.String idmlSourcePath)
          This constructor requires an XSL directory to locate the transforms and an IDML Package containing the images to be replaced.
 
Method Summary
 void cleanup()
          Removes the temporary directory used for IDML Package extraction.
 void exportList(java.lang.String outputFilePath)
          Writes a the image ID's and paths to an XML File.
 java.util.Hashtable<java.lang.String,java.lang.String> getLinksFromPackage()
          Gets a the image ID's and links from the source IDML Package in a Hashtable.
 void importList(java.lang.String importXmlPath, java.lang.String idmlOutputPath)
          Imports an XML file with image ID's mapped to links and applies the changes to a copy of the source IDML Package.
static void main(java.lang.String[] args)
          The main method used to initialize the ReplaceImages class.
 void setSourcePackage(java.lang.String idmlSourcePath)
          Set the IDML Package in which to replace images.
 void updatePackage(java.util.Hashtable<java.lang.String,java.lang.String> links, java.lang.String idmlOutputPath)
          Makes a copy of the source IDML Package and updates the links with the values found in the links Hashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplaceImages

public ReplaceImages(java.lang.String xslDirPath,
                     java.lang.String idmlSourcePath)
              throws java.io.IOException
This constructor requires an XSL directory to locate the transforms and an IDML Package containing the images to be replaced.

Parameters:
xslDirPath - The path to the XSL directory containing the XSL files used to transform Package XML files.
idmlSourcePath - The path to the IDML Package file containing images to be replaced.
Throws:
java.io.IOException
Method Detail

setSourcePackage

public void setSourcePackage(java.lang.String idmlSourcePath)
                      throws java.io.IOException
Set the IDML Package in which to replace images.

Parameters:
idmlSourcePath - The path to the IDML Package.
Throws:
java.io.IOException

exportList

public void exportList(java.lang.String outputFilePath)
                throws java.io.IOException,
                       javax.xml.xpath.XPathExpressionException,
                       PackageException,
                       javax.xml.parsers.ParserConfigurationException
Writes a the image ID's and paths to an XML File.

Parameters:
outputFilePath - The XML file where the image ID's and paths will be written to.
Throws:
java.io.IOException
javax.xml.xpath.XPathExpressionException
PackageException
javax.xml.parsers.ParserConfigurationException

importList

public void importList(java.lang.String importXmlPath,
                       java.lang.String idmlOutputPath)
                throws javax.xml.xpath.XPathExpressionException,
                       PackageException,
                       java.io.IOException,
                       javax.xml.transform.TransformerFactoryConfigurationError,
                       javax.xml.transform.TransformerException
Imports an XML file with image ID's mapped to links and applies the changes to a copy of the source IDML Package.

Parameters:
importXmlPath - The path to the XML file to be imported.
idmlOutputPath - The path to the IDML file which will be created after applying the changes to the source IDML package.
Throws:
javax.xml.xpath.XPathExpressionException
PackageException
java.io.IOException
javax.xml.transform.TransformerFactoryConfigurationError
javax.xml.transform.TransformerException

cleanup

public void cleanup()
Removes the temporary directory used for IDML Package extraction.


getLinksFromPackage

public java.util.Hashtable<java.lang.String,java.lang.String> getLinksFromPackage()
                                                                           throws java.io.IOException,
                                                                                  javax.xml.xpath.XPathExpressionException,
                                                                                  PackageException
Gets a the image ID's and links from the source IDML Package in a Hashtable.

Returns:
A Hashtable containing the image ID's mapped to image links.
Throws:
java.io.IOException
javax.xml.xpath.XPathExpressionException
PackageException

updatePackage

public void updatePackage(java.util.Hashtable<java.lang.String,java.lang.String> links,
                          java.lang.String idmlOutputPath)
                   throws java.io.IOException,
                          javax.xml.transform.TransformerFactoryConfigurationError,
                          javax.xml.transform.TransformerException
Makes a copy of the source IDML Package and updates the links with the values found in the links Hashtable.

Parameters:
links - A Hashtable with link ID/Path Key/Value pairs.
idmlOutputPath - The IDML Package file that will be created by copying the links file paths to the source IDML package.
Throws:
java.io.IOException
javax.xml.transform.TransformerFactoryConfigurationError
javax.xml.transform.TransformerException

main

public static void main(java.lang.String[] args)
The main method used to initialize the ReplaceImages class.

Parameters:
args - parameters provided by the console application.


Copyright © 2008 Adobe Systems Incorporated. All Rights Reserved.