Create Document with Metadata

A file’s embedded internal information is called its metadata. All files created on your computer include a certain amount of metadata. It is this information that makes it possible for files to be searched and found. More importantly, if you publish your ePub creation, the metadata included makes it possible for it to be found “out there” in the vast sea of available titles.

Because this information is “hidden”, you need some way to peek inside the file. There are several methods, most commonly:

  • Bridge – Navigate to the file using Bridge’s Content window. Open Bridge’s Metadata panel (Window > Metadata). When you click on a file, its metadata shows up under File Properties.
  • Application – Open the document using its creator application. Somewhere within the various menu items, you should find an entry named File Info. For InDesign, this is under the File menu. Should you want to add metadata to your document manually, this is where you would do it.

If you create a document without adding any metadata, critical information such as filename, document type, and date created are added by InDesign to its metadata automatically.

When it comes to creating an ePub there is some additional information required, specifically the publication ID. This you provide as part of the export process in the EPUB Export Options, Advanced panel. If you have an ISBN number for your publication, enter it in the Unique ID field. Otherwise, use the ID generated by InDesign. You will also want to add the name of the publisher, and check Include Document Metadata. This latter option assumes that you have added metadata to your document.

Adding Metadata

Although not required, there are two pieces of information you want to add to your ePub file: the Document Title and Author. Without this, InDesign will use the name of your document for the Document Title and “unknown” for the author.

Optionally, you may want to add Description, Keywords, and Copyright information. Because copyright information often remains pretty much the same for your ePubs, you can include this as part of the template used to create the document. Alternatively, you could hard code the copyright information into the script you use to create your document.

Try the following with a document that has been saved without your having added metadata. After running the script, open the File Info window to view the result.

AppleScript

(*Metadata information to be returned from a custom dialog*)
set metaTitle to "Title for Publication"
set mAuthor to "Name of author"
set metaDesc to "Enter description of document here"
set metaKeys to {"test", "metadata"}
set mJobName to "Job Name"
(*Copyright information could be hard-coded in script*)
set mNotice to "Copyrighted 2013 Your Name"
set metaURL to "www.yourURL.com"
(*Assumes document is open and has been saved*)
tell application "Adobe InDesign CC"
     set docRef to document 1
     tell metadata preferences of docRef
          set copyright notice to mNotice
          set copyright status to yes
          set document title to metaTitle
          set job name to mJobName
          set author to mAuthor
          set description to metaDesc
          if metaKeys is not missing value then set keywords to metaKeys
          if metaURL is not missing value then set copyright info URL to metaURL
     end tell
     save docRef
end tell

ExtendScript

/*Metadata information to be returned from a custom dialog*/
var metaTitle = "Title for Publication";
var metaName = "Name of ePub";
var mAuthor = "Name of Author";
var metaDesc = "Enter description for document here";
var metaKeys = ["test", "metadata"];
var mJobName = "Job Name";
/*Copyright information could be har-coded in script*/
var mNotice = "Copyrighted 2013 Your Name";
var metaURL = "www.yourURL.com";
/*Assumes document is open and has been saved*/
var docRef = app.documents.item(0);
var metaPrefs = docRef.metadataPreferences;
metaPrefs.copyrightNotice = mNotice;
metaPrefs.copyrightStatus = CopyrightStatus.YES;
metaPrefs.documentTitle = metaTitle;
metaPrefs.jobName = mJobName;
metaPrefs.author = mAuthor;
metaPrefs.description = metaDesc;
if (metaKeys != undefined) metaPrefs.keywords = metaKeys;
if (metaURL != undefined) metaPrefs.copyrightInfoURL = metaURL;
docRef.save();

Creating the Document

Of course you want to use a script to create your document. Besides saving you a couple of trips to the Finder, scripts can provide workflow consistency with possibly fewer errors and oversights.

In addition to the script providing a means for adding metadata to your document, you might consider the following additional functionality:

  • Present the user with a list of document template names and create the document from the template chosen.
  • Present the user with a list of document presets, and create the document from the preset chosen.
  • Present the user with a list of document stylesheets and import styles and color swatches from the stylesheet chosen.
  • Establish ePub export preferences
  • Save the document in a folder named the same as the document in a pre-defined location.

Using a Document Preset

For your Create ePub Document script you may want to present the user with a list of document presets from which to choose. For this you might want to list only those presets which have web intent.

AppleScript

tell application "Adobe InDesign CC"
     set presetList to (every document preset where intent is web intent) as list
end tell

ExtendScript

var presetArr = [];
var allPresets = app.documentPresets;
for (var i =0; i < allPresets.length; i++ ) {
     if (allPresets[i].intent == DocumentIntentOptions.WEB_INTENT) { 
          presetArr.push(allPresets[i].name);
     }
}

Setting ePub Export Preferences

With so many export preference options, you may prefer to allow your user to use InDesign’s user interface. You could ensure that some preferences such as include document metadata are set to true by default by setting this value in your script:

AppleScript

tell application "Adobe InDesign CC"
     tell document 1
          tell EPub export preferences
               set include document metadata to true
          end tell
     end tell
end tell

ExtendScript

var docRef = app.documents.item(0);
var myExportPrefs = docRef.epubExportPreferences;
myExportPrefs.includeDocumentMetadata = true;

On Your Own

You may be want to think of other functionality you would want to add to your Create EPub Document script. Until then, look for our sample script to be posted to both the AppleScript and ExtendScript pages.