Creating and Updating PDF Xpath metadata

Post Reply
samisuihkonen
Newbie
Posts: 1
Joined: Fri Aug 03, 2018 9:27 am

Creating and Updating PDF Xpath metadata

Post by samisuihkonen »

Hi!

We´re testing using pdf metadata in our workflows and we have a problem updating Xpath data (Title, Author, Subject etc) via scripting. We´ve managed to update this data, if the pdf already has something in those fields. If the fields are empty, the xmp (xml) data structure doesn´t have the tags in the data tree and we can´t figure out how to create the tags needed via scripting. Here´s the Switch script we´re trying, but it doesn´t create anything to the xmp tree...

function jobArrived( s : Switch, job : Job )
{
//get a writable XMP Dataset
var ds = job.getEmbeddedDataset(true);

var pdfTitle = s.getPropertyValue("pdfTitle");
var pdfAuthor = s.getPropertyValue("pdfAuthor");
var pdfSubject = s.getPropertyValue("pdfSubject");
var keyword1 = s.getPropertyValue("keyword1");
var keyword2 = s.getPropertyValue("keyword2");
var keyword3 = s.getPropertyValue("keyword3");

//get the default prefixmap
var map = ds.createDefaultMap();

ds.setString('dc:title/*[1]', map, pdfTitle);
//ds.setString('dc:title/*[x-default]', map, 'John Doe');
ds.setString('mns:general/mns:author', map, 'John Doe');
ds.setString('xmp:general/mns:author', map, 'John Doe');
ds.setString('dc:creator/*[1]', map, pdfAuthor);
ds.setString('dc:description/*[1]', map, pdfSubject);
ds.setString('dc:subject/*[1]', map, keyword1);
ds.setString('dc:subject/*[2]', map, keyword2);
ds.setString('dc:subject/*[3]', map, keyword3);

//finished with writing
ds.finishWriting();

//save file
job.sendToSingle(job.getPath());
}
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Creating and Updating PDF Xpath metadata

Post by Padawan »

I think you'll need to update your prefixmap. I found an earlier post here which explains this:

viewtopic.php?f=13&t=35&p=121&hilit=namespace+map#p122

Edit:
I also found the part of the scripting documentation discussing the adding of prefixmaps:
http://www.enfocus.com/manuals/Develope ... class.html
Post Reply