InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SnpPerformXMPCommands Class Reference

Public Member Functions

 SnpPerformXMPCommands ()
 
virtual ~SnpPerformXMPCommands ()
 
virtual ErrorCode ReplaceMetaDataFromFile (IPMUnknown *targetObject, const IDFile &sysFile, bool16 stripForeignData=kFalse)
 
virtual ErrorCode AppendMetaDataFromFile (IPMUnknown *targetObject, const IDFile &sysFile)
 
virtual ErrorCode SaveMetaDataToFile (IPMUnknown *targetObject, const IDFile &sysFile)
 
IMetaDataAccessQueryMetaData (IPMUnknown *targetObject)
 

Detailed Description

  • Shows how to use XMP commands available in the InDesign/InCopy API.

A bit of background about XMP MetaData support in InDesign/InCopy:

In InDesign/InCopy, you can use the File >> File Info... menu item to open a dialog that gives you access to the MetaData related operations for your InDesign/InCopy document. In that dialog, you can do things such as:

  • Set or view the MetaData for the document.
  • "Replace" MetaData from an *.XMP (text, XML) file.
  • "Save" the MetaData to an *.XMP (text, XML) file.

Using XMP, you can attach metadata to your document, or information about the content of your document. For example, you can store these items as MetaData:

  • Standard InDesign/InCopy MetaData: author, title, keywords, etc.
  • The source of the information contained in the document.
  • Your own MetaData that needs to be part of the PDF you can export from InDesign/InCopy. Please note that when you export your InDesign document to PDF (with at least Acrobat 5.0 compatibility), the MetaData also becomes part of the PDF.

This codesnippet shows some of the API commands that do the same thing, so you can automate your workflow involving MetaData.

For more information about using MetaData in the InDesign/InCopy application, consult the InDesign/InCopy on-line help.

For general information about XMP, refer either to the XMP Overview Page (http://www.adobe.com/products/xmp/main.html).

To incorporate XMP into your custom application outside of InDesign, refer to the XMP Toolkit Download page (http://partners.adobe.com/asn/developer/xmp/download/).

How to use this snippet

First, 'save' the MetaData from the current document to a file. Then using a text editor, modify the data inside some of the existing XMP MetaData "paths", and then 'replace'. Make further changes, such as adding in new custom schemas, and then 'append'. Then view how the MetaData changed in the File Information dialog.

XMP Programming Use cases:

  1. How do I save MetaData to file?
    Query the IMetaDataAccess interface on the boss with the MetaData model, and call the SaveToStream() method. (See SnpPerformXMPCommands::SaveMetaDataToFile())

  2. How do I load MetaData from file?
    Process the kReplaceMetaDataCmdBoss (formerly known as kLoadMetaDataCmdBoss in 2.x). Specify the target boss (e.g. document) and the IDFile in the IReplaceMetaDataCmdData data interface (which used to be ILoadMetaDataCmdData in 2.x). Optionally, you can strip MetaData that is not part of the default InDesign MetaData set, by processing kStripForeignMetaDataCmdBoss. This corresponds to the OFF state of the "Preseve additional MetaData" checkbox in the File >> File Info... dialog. (See SnpPerformXMPCommands::ReplaceMetaDataFromFile())

  3. How do I merge MetaData from file?
    Process the kAppendMetaDataCmdBoss (formerly known as kMergeMetaDataCmdBoss in 2.x). Specify the target boss (e.g. document) and the IDFile in the IAppendMetaDataCmdData data interface (which used to be IMergeMetaDataCmdData in 2.x) (See SnpPerformXMPCommands::AppendMetaDataFromFile())

  4. How do I get the value of a particular MetaData object?
    Query the IMetaDataAccess interface on the boss with the MetaData model, and call the Enumerate() or Get() methods. (See SnpInspectXMPMetaData)

  5. How do I count the number of data elements of a particular MetaData tag?
    Query the IMetaDataAccess interface on the boss with the MetaData model, and call the Count() method.

  6. How do I modify (set, append, create a new path, remove) the value of a particular MetaData object?
    If you want to set the value of a default InDesign MetaData tag, process one of the kSetAdobe...Cmd commands listed under "Low-level MetaData commands" below.
    If you want to set the value of a custom MetaData tag (a.k.a. foreign MetaData), you will need to create a custom command. Inside this custom command, query the IMetaDataAccess interface on the boss with the MetaData model, and call the AppendArrayItem() (if necessary), Set(), Remove(), SetBoolean(), SetDateTime() or ClearAllProperties() method.
    To get a list of existing namespaces, run the SnpInspectXMPMetaData snippet on an InDesign document, but without any parameters for the snippet. Alternatively, you can refer to the XMP Documentation.

Reference:

Related interfaces (in order of importance):

<UL>

<LI>IMetaDataAccess is a wrapper to IMetaData as well as the XMP 

        Toolkit API.</LI>

<LI>IMetaDataIterator is an iterator interface for MetaData 

        objects.</LI>

<LI>IAdobeBasicJobMetaData is a data interface to store and retrieve 

        Adobe Basic Job MetaData. </LI>

<LI>IAdobeCoreMetaData is a data interface to store and retrieve 

        Adobe Core MetaData.</LI>

<LI>IAdobeMediaMgmtMetaData is a data interface to store and retrieve 

        Adobe Media Management MetaData.</LI>

<LI>IAdobeRightsMgmtMetaData is a data interface to store and retrieve 

        Adobe Rights Management MetaData.</LI>

<LI>ICalculateMetaData is a helper interface used by the MetaDataResponder 

        to calculate Adobe core MetaData.</LI>

<LI>ILoadMetaData is a helper interface used by kLoadMetaDataCmdBoss and 

        kStripForeignMetaDataCmdBoss. (This interface was obsoleted in 3.0)</LI>

<LI>IMergeMetaData is a helper interface used by kMergeMetaDataCmdBoss.

        (This interface was obsoleted in 3.0)</LI>

<LI>IMetaData is used for the MetaData model, and should only be used from

         within a command.</LI>

</UL>



Other Includes to use:

<UL>

<LI>MetaDataID.h</LI>

<LI>MetaDataTypes.h (included by various MetaData interfaces)</LI>

</UL>



Boss classes that have a MetaData model (look for IMetaData):

<UL>

<LI>kDocBoss is the MetaData model associated with a document.

<LI>kMetaDataBoss is a generic MetaData model.

</UL>



High-level MetaData commands:

<UL>

<LI>kAppendMetaDataCmdBoss is in this codesnippet. Appends MetaData from a IDFile.  Uses IAppendMetaDataCmdData.

<LI>kReplaceMetaDataCmdBoss is in this codesnippet. Loads MetaData from a IDFile and replaces the current document's metadata with it.  Uses IReplaceMetaDataCmdData.

</UL>



Low-level MetaData commands:

<UL>

<LI>kSetAdobeCoreMetaDataCmdBoss sets the Adobe Core MetaData.  Uses ISetAdobeCoreMDCmdData.

<LI>kSetAdobeRightsMgmtMDCmdBoss sets the Adobe Core MetaData.  Uses ISetAdobeCoreMDCmdData.

<LI>kSetAdobeBasicJobMDCmdBoss sets the Adobe Core MetaData.  Uses ISetAdobeCoreMDCmdData.

<LI>kSetAdobeMediaMgmtMDCmdBoss sets the Adobe Core MetaData.  Uses ISetAdobeCoreMDCmdData.

<LI>kStripForeignMetaDataCmdBoss removes the non-Adobe MetaData.  Uses IStripForeignMetaDataCmdData.

</UL>

See Also
IAdobeMediaMgmtMetaData
IAdobeRightsMgmtMetaData
ICalculateMetaData
IMetaData
IMetaDataAccess
IAdobeBasicJobMetaData
IAdobeCoreMetaData
IAppendMetaDataCmdData
IMetaDataAccess
IMetaDataIterator
IReplaceMetaDataCmdData
IStripForeignMetaDataCmdData

Constructor & Destructor Documentation

SnpPerformXMPCommands::SnpPerformXMPCommands ()
inline

Constructor.

virtual SnpPerformXMPCommands::~SnpPerformXMPCommands ()
inlinevirtual

Destructor.

Member Function Documentation

ErrorCode SnpPerformXMPCommands::AppendMetaDataFromFile (IPMUnknowntargetObject,
const IDFilesysFile 
)
virtual

Appends the MetaData from a file into a boss class (e.g. document).

Parameters
targetObjectIN The target boss class (e.g. document) to merge MetaData into.
sysFileIN sysfile to read from.
Returns
Status. Returns kSuccess if success.
IMetaDataAccess * SnpPerformXMPCommands::QueryMetaData (IPMUnknowntargetObject)

Obtains a pointer to the IMetaDataAccess interface in a boss class (e.g. kDocBoss).

Parameters
targetObjectThe target boss class (e.g. document) to obtain MetaData from.
Returns
IMetaDataAccess*. nil if not found in boss class.
ErrorCode SnpPerformXMPCommands::ReplaceMetaDataFromFile (IPMUnknowntargetObject,
const IDFilesysFile,
bool16 stripForeignData = kFalse 
)
virtual

Replaces the XMP MetaData from a file with that of a boss class (e.g. document).

Parameters
targetObjectIN The target boss class (e.g. document) to put MetaData into.
sysFileIN sysfile to read from.
stripForeignDataIN kTrue if you want to remove MetaData that is not part of the InDesign default MetaData set. The default XMP data for InDesign consists of MetaData stored using the following interfaces.
Returns
Status. Returns kSuccess if success.
ErrorCode SnpPerformXMPCommands::SaveMetaDataToFile (IPMUnknowntargetObject,
const IDFilesysFile 
)
virtual

Saves the MetaData in the boss class (e.g. document) to the file.

Parameters
targetObjectThe target boss class (e.g.: document) to obtain MetaData from.
sysFileIN sysfile to read from.
Returns
Status. Returns kSuccess if success.