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

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

Engaged ,
Jan 18, 2025 Jan 18, 2025

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");
}

 

TOPICS
Scripting
570
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
Adobe
Enthusiast ,
Jan 18, 2025 Jan 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
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
Engaged ,
Jan 18, 2025 Jan 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

 

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
Enthusiast ,
Jan 18, 2025 Jan 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
  * @Version 1.0.0
  * @author sttk3.com
*/

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

/**
  * Returns whether or not overprint preview now
  * @Param {Document} doc target document
  * @Returns {boolean}
*/
function isOverprintPreview(doc) {
  return (doc.getViewMode() === 'OverprintPreview') ;
}
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
Engaged ,
Jan 18, 2025 Jan 18, 2025

What version of Illustrator will getViewMode() work with ? I didn't find any info about getViewMode function.

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
Enthusiast ,
Jan 18, 2025 Jan 18, 2025

Tried it and it seems to be usable from Illustrator 2023.

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
Enthusiast ,
Jan 19, 2025 Jan 19, 2025
LATEST

I checked the pdf documents ADOBE ILLUSTRATOR SCRIPTING REFERENCE: JAVASCRIPT and only the latest versions 2023, 2024, 2025 contain information about getViewMode()

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