How to detect new units if RulerUnits.Unknown

The script didn’t detect the feet units
  • stDim:h — height,
  • stDim:unit — ruler units.
<xmpTPg:MaxPageSize rdf:parseType="Resource">
  • get data from activeDocument.XMPString,
  • find the field stDim:unit,
  • retrieve the name of the units, e.g. by searching for matches of the exec() string.
var doc = activeDocument;
if (doc.rulerUnits == RulerUnits.Unknown) {
var xmp = doc.XMPString;
var units = '';
if (/stDim:unit/i.test(xmp)) {
units = /<stDim:unit>(.*?)<\/stDim:unit>/g.exec(xmp)[1];
alert('Current units: ' + units);
After saving the document the units are read from XMP



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Sergey Osokin. I’m a illustrator & Script Developer (Ai, Ps). Writing about bugs and tricks.