Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script to detect Overprint within a document

Explorer ,
May 15, 2023 May 15, 2023

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!

TOPICS
Experiment , How-to , Print and publish , Scripting
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 15, 2023 May 15, 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
...
Translate
Adobe
Community Expert ,
May 15, 2023 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

 

hasOverprint.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2023 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2023 May 15, 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");
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 18, 2023 May 18, 2023
LATEST

This works like a charm. Below is the Frankenstein of a script that I came up with. The script below essentially just prompts the user to select files to check. Will definitely be messing around with this to see what other useful data I can extract from the Metadata and make more human redable for the people on my team.

 

//Load the external library

if ( ExternalObject.AdobeXMPScript == undefined ) {

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

}

//Namespace and property name

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

//Variable to store files and the generated alert string

var allFiles;
var alertString = "Selected File(s) Overprint Settings\n";

//Prompt the user to open files for checking

allFiles = File.openDialog("Please select files to check.", undefined, true);

//Loop through the files selected by the user and check for overprint in the metadata

for(var i = 0; i < allFiles.length; i++) {

  //Get metadata for the current file

  var currentXMP = new XMPFile(allFiles[i].fsName, 0, XMPConst.OPEN_FOR_READ);
  var packetXMP = currentXMP.getPacketInfo();
  var currentMeta = new XMPMeta(packetXMP.packet);

  //Check if the property exists in the data

  var propTest = currentMeta.doesPropertyExist(nameSpace, propName);

  //Name of the current file

  var activeName = allFiles[i].name;

  //Append to the alert string based on the existense of the property

  if(propTest) {

    //Get the property value

    var activeProperty = currentMeta.getProperty(nameSpace, propName);

    //Add to the alert string

    alertString = alertString + activeName + "\nVisible Overprint: " + activeProperty + "\n\n";

  }else {

    //Add to the alert string

    alertString = alertString + activeName + "\nVisible Overprint: UNAVAILABLE";

  }
}

//Display to the user which of the selected files have visible overprint

alert(alertString);

 

Thanks so much for your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines