Skip to main content
Participant
January 16, 2009
Question

Select objects with a fill color of CMYK black and set overprint to yes

  • January 16, 2009
  • 3 replies
  • 1153 views
Hi. I am new to JavaScript for Illustrator CS3.

I have a complex action set to process PDF files through Illustrator CS3.
I am trying to convert the actions to JavaScript .jsx files.

I want to select all text objects, path objects and stroke objects that have a CMYK fill value of 0,0,0,100.
With this active selection I want to set the overprint fill to true.
Then deselect these objects.

I can set the default color swatches, I can select all objects but I am stuck with selecting by a fill color.

Any advice would be greatly appreciated.
This topic has been closed for replies.

3 replies

try67
Community Expert
Community Expert
January 19, 2009
A pageItem can refer to any art item in the page, not all of which will have the fillOverprint or fillColor property, for example. Hence the error.
You should either check the pageItem's typename first, or change the loop to iterate over just the items you want to change.
Participant
January 19, 2009
Hi John,<br /><br />Thanks for the reply. I'm not sure how to iterate through an array, but here is my first attempt at selecting path items.<br /><br />var docRef=app.activeDocument; <br />for(i=0;i<docRef.pageItems.length; i++ ) {<br /> var pathRef = docRef.pageItems;<br /> if (pathRef.fillColor.black == 100) {<br /> pathRef.selected = true;<br /> pathRef.fillOverprint = true;<br /> }<br /> }<br /><br />I get an error "undefined is not an object". Any ideas what I've done wrong? It did work the first time though....weird!?<br /><br />I assume if the path items works, I can reuse the code for text items.
Known Participant
January 16, 2009
Rachel -

There is no way that I know to select objects based on color.

Start with a collection of the objects you want to test ( ie: activeDocument.pathItems, textFrames, etc)

Then iterate through that array doing tests against fill and stroke color.

Hope that helps.