Skip to main content
TySprice
Known Participant
May 15, 2023
Answered

Script to detect Overprint within a document

  • May 15, 2023
  • 1 reply
  • 1761 views

I work at a large commercial printing company. Things being set to overprint when they shouldn’t be is a huge recurring problem leading to many re-prints and a lot of loss financially.

 

Ideally, I would like to implement a script that can detect if an Illustrator document contains items that are set to overprint. I am curious if there is any way of achieving this without needing to loop through every single thing in the document. I don’t need to modify the overprint setting on anything. I simply would like to alert the user if the document has anything set to overprint. If anyone knows of any method of detecting this on the document level, I would be forever grateful. Or if there are any other methods of achieving this, I am all ears.

 

Thanks!

This topic has been closed for replies.
Correct answer CarlosCanto

try this with an active document 

 

// load the library
if (ExternalObject.AdobeXMPScript == undefined) {
    ExternalObject.AdobeXMPScript = new
    ExternalObject("lib:AdobeXMPScript");
}

var ns = "http://ns.adobe.com/xap/1.0/t/pg/";
var propertyname = "HasVisibleOverprint";

//Create an XMPMeta object from the active documents XMPString:
var myXmp = new XMPMeta(app.activeDocument.XMPString);

// retrieve property if it exists
var doesprop = myXmp.doesPropertyExist(ns, propertyname); // true

if (doesprop) {
    var prop = myXmp.getProperty(ns, fieldName); 
    alert("namespace: " + prop.namespace  + "\n\nproperty name: " + propertyname + "\n\nvalue: " + prop);
}
else {
    alert (propertyname + " was not found");
}

 

1 reply

CarlosCanto
Community Expert
Community Expert
May 15, 2023

there's a way, it could be scripted but for now you can check manually

 

- go to File->File Info...

- click on the Raw Data Section on left of the XMP metadata window

- type "hasVisibleOverprint" in the search field to go to the field

- you should see True or False

 

TySprice
TySpriceAuthor
Known Participant
May 15, 2023

Hey, this is immensely helpful. Thank You!

When I run the following script it spits out "Undefined". I would imagine it is because it can't find the property. I have the document saved as a PDF. I believe I am using the correct namespace URI. However, when I include the prefix with the property name (xmpTPg:HasVisibleOverprint) it indicates that there is a Schema namespace URI and prefix mismatch. Is there a different namespace URI that I should be using? Or am I just off base in thinking that we have access to this metadata using the AdobeXMPScript library?

if ( ExternalObject.AdobeXMPScript == undefined ) {

    ExternalObject.AdobeXMPScript = new ExternalObject( "lib:AdobeXMPScript");

}

var currentDoc = app.activeDocument;
var fileName = currentDoc.fullName;
var fixName = fileName.fsName;

var docXMPFile = new XMPFile(fixName, 0, XMPConst.OPEN_FOR_READ);
var docXMPData = docXMPFile.getPacketInfo();

var docXMPMeta = new XMPMeta(docXMPData.packet);

var overPrint = docXMPMeta.getProperty(XMPConst.NS_PDF, "HasVisibleOverprint");

alert(String(overPrint));

 Really appreciate the help!

 

Thanks!

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
May 16, 2023

try this with an active document 

 

// load the library
if (ExternalObject.AdobeXMPScript == undefined) {
    ExternalObject.AdobeXMPScript = new
    ExternalObject("lib:AdobeXMPScript");
}

var ns = "http://ns.adobe.com/xap/1.0/t/pg/";
var propertyname = "HasVisibleOverprint";

//Create an XMPMeta object from the active documents XMPString:
var myXmp = new XMPMeta(app.activeDocument.XMPString);

// retrieve property if it exists
var doesprop = myXmp.doesPropertyExist(ns, propertyname); // true

if (doesprop) {
    var prop = myXmp.getProperty(ns, fieldName); 
    alert("namespace: " + prop.namespace  + "\n\nproperty name: " + propertyname + "\n\nvalue: " + prop);
}
else {
    alert (propertyname + " was not found");
}