Question
Property doesn't write when schema isn't present.
app.document.deselectAll();
var count = app.document.visibleThumbnailsLength;
app.synchronouseMode=true;
for ( var i = 0; i < count; i++ ) {
if ( app.document.visibleThumbnails[i].name.indexOf("-lr")==-1&&app.document.visibleThumbnails[i].name.split(".")[1]=="pdf") {
var selectedFile = app.document.visibleThumbnails[i].spec;
app.document.select( app.document.visibleThumbnails[i] );
var thumbnailMeta=app.document.visibleThumbnails[i].metadata;
//var addIPTC_Core=thumbnailMeta.applyMetadataTemplate ("Imaging_Template_1.0","append");
$.writeln(thumbnailMeta)
if (ExternalObject.AdobeXMPScript == undefined){
ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
}
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
So if I use this library I am only able to write to this file if that schema exists. Right now I have a PDF that just has some custom metatdata and I want to add some ITPC_Core metat data to it but That schema doesn't exist. So I either need to figure out how to write to the custom schema or create a new ITPC_Core schema and then edit that. Any help is appreciated.
function setXMPValue (xmpType,propertyValid,propertyToSet,propertyValue,propertyFlag){
// var Email = myXmp.getStructField( XMPConst.NS_IPTC_CORE, "CreatorContactInfo",XMPConst.NS_IPTC_CORE, "CiEmailWork");///gets the value of the structure
try{
if(propertyValid){
myXmp.setArrayItem(xmpType, propertyToSet,1,propertyValue);
}
else{
if(propertyFlag=="field"){
//if the property is nested and does not exists already we have to setStructField which requires a different constructor
var setAField= myXmp.setStructField( XMPConst.NS_IPTC_CORE, "CreatorContactInfo",XMPConst.NS_IPTC_CORE, "CiEmailWork",propertyValue);///sets the value of the structure for field
}
else{
myXmp.appendArrayItem(xmpType, propertyToSet, propertyValue, 0, XMPConst.PROP_IS_ARRAY);
}
}
}
catch(err){
$.writeln(err)
}
}
