Mit Metadata eksempel (fra InDesign Developer sitet)
//MetadataExample.jsx
//An InDesign CS5 JavaScript
//Adds metadata to an example document.
main();
function main(){
//mySetup();
mySnippet();
myTeardown();
}
//<setup>
//function mySetup(){
// app.documents.add();
//}
//</setup>
//<snippet>
function mySnippet(){
//Adds metadata to an example document.
var myDocument = app.documents.item(0);
//<fragment>
with (myDocument.metadataPreferences){
author = "Adobe";
copyrightInfoURL = "
http://www.adobe.com"; copyrightNotice = "This document is copyrighted.";
copyrightStatus = CopyrightStatus.yes;
description = "Example of xmp metadata scripting in Adobe InDesign CS4";
documentTitle = "XMP Example";
jobName = "XMP_Example_2008";
keywords = ["animal", "mineral", "vegetable"];
//The metadata preferences object also includes the read-only
//creator, format, creationDate, modificationDate, and serverURL
//properties that are automatically entered and maintained by InDesign.
//Create a custom XMP container, "email"
var myString = "
http://ns.adobe.com/xap/1.0/"; var myNewContainer = createContainerItem(myString, "email");
setProperty(myString, "email/*[1]", "someone@adobe.com");
}
//</fragment>
}
//</snippet>
//<teardown>
function myTeardown(){
}
//</teardown>
Du kunne så ligge denne funktion ind også. Husk at ligge en reference til "myExport()" i øverste kode.
Du skal jo alligevel eksportere en pdf, så du kan ligeså godt koble metadata på og eksportere i et go.
function myExport(){
//<fragment>
var myDocument = app.documents.item(0);
//The document.export parameters are:
//Format as (use either the ExportFormat.pdfType enumeration
//or the string "Adobe PDF")
//To as File
//ShowingOptions as boolean (setting this option to true displays the
//PDF Export dialog box)
//Using as PDF export preset (or a string that is the name of a
//PDF export preset)
//The default PDF export preset names are surrounded by square breackets
//(e.g., "[High Quality Print], [Press Quality], or [Smallest File Size]").
var myPDFExportPreset = app.pdfExportPresets.item("[Press Quality]");
myDocument.exportFile(
ExportFormat.pdfType,
File(Folder.desktop + "/ExportPDFWithPreset.pdf"),
false,
myPDFExportPreset
);
//</fragment>
}
Hvis du har InDesign Cs5 kan du endvidere koble scriptet op mod dine egne knapper hvis du leger med configurator2 (fra adobe labs - labs.adobe.com)