Skip to main content
Inspiring
January 18, 2025
Question

How do I check in a script that Overprint Preview has already been enabled?

  • January 18, 2025
  • 1 reply
  • 658 views

In Adobe Illustrator, is there a way to check the Overprint Preview status (it looks like Overprint Preview is a property of the document) through a script? I have tried catching an error if I try to re-enable it, however that does not work.

 

try {
  app.executeMenuCommand('ink');
  alert("on");
} catch (e) {
  alert("already enabled");
}

 

1 reply

Legend
January 18, 2025

For example, it may be possible to determine this by examining the Window title using AppleScript. When overprint preview is used, the title will include that. It would be a good idea to use ends with it as a criterion, in case the document name includes it.

 

Not sure if it works correctly in an English environment since the actual environment I tested it in is in another language, but it was successful anyway.

on run
	set is_overprint_preview to false
	tell application "System Events"
		tell application process "Adobe Illustrator"
			set window_title to title of window 1
			if window_title ends with "Overprint Preview) " then
				set is_overprint_preview to true
			end if
		end tell
	end tell
	
	return is_overprint_preview
end run
Inspiring
January 18, 2025

@sttk3 When you say the Window title you obviously mean a document window title? When I get the window title in JavaScript it does not include info about  overprint preview.

 

app.activeDocument.name  //test.ai

 

Legend
January 18, 2025

I didn't know this until just now, but there is a function that returns the current view mode. This solves the problem.

/**
  * @File Returns whether or not overprint preview now
  * https://community.adobe.com/t5/illustrator-discussions/how-do-i-check-in-a-script-that-overprint-preview-has-already-been-enabled/td-p/15098023
  * @3653945.0.0
  * @7111211 sttk3.com
*/

(function() {
  if(app.documents.length <= 0) {return ;}
  var doc = app.documents[0] ;
  alert(isOverprintPreview(doc)) ;
})() ;

/**
  * Returns whether or not overprint preview now
  * @9397041 {Document} doc target document
  * @Returns {boolean}
*/
function isOverprintPreview(doc) {
  return (doc.getViewMode() === 'OverprintPreview') ;
}