Skip to main content
Inspiring
November 10, 2022
Question

How to toggle Printing/Non Printing for graphic objects

  • November 10, 2022
  • 5 replies
  • 1562 views

I need to toggle Rectangle Frames to non printing to send to a client so that their editor can review the text & flow. The project is too far along to transfer all of the images to another layer and then just turn off the layer.

 

I know I can do it individually for each item, however that can take hours everytime I need to send a copy to the client. 

 

I've looked but have not found a script or utility that would "en mass" change the status of all Rectangle Frames   in a particular layer to non printing.

 

Looking forward to your suggestions.

This topic has been closed for replies.

5 replies

ht354Author
Inspiring
November 11, 2022

Gentlemen, I thank you for the solutions and the effort. Your work really drives home the fact that I need to start my journey in the JavaScript world.

Peter Kahrel
Community Expert
Community Expert
November 10, 2022

Aha -- Brian beat me to it. Two different approaches for you.

 

P.

Community Expert
November 10, 2022

There's a script here that can move all images to a new layer - not sure if it works for your needs

https://creativepro.com/topic/script-to-move-all-imagesgraphics-to-a-new-layer/

 

If it would be worth your while to create an Object Style

And select one of the images you want to set to non printing

And create a style for it

In the Attributes set it to non-printing and redefine the style

 

then you just have to turn off the non printing for 1 image and redefine the style to toggle it

 

Perhaps it can be scripted. 

Community Expert
November 10, 2022

Well, I went to take up the dinner and two scripts written while I was away .. ha ha great stuff.

brian_p_dts
Community Expert
Community Expert
November 10, 2022

 

 

var layerName = "Layer X";
var apis = app.activeDocument.allPageItems;
var i = apis.length;
while(i--) {
    if (apis[i] instanceof Rectangle && apis[i].itemLayer.name == layerName) {
        apis[i].nonprinting = true; //change true to false to undo
    }
}

 

 

EDIT: Here's a refined version that would nonprint all graphic containers, not just rectangles. 

 

var layerName = "Layer X";
var apis = app.activeDocument.allGraphics;
var i = apis.length;
var p;
while(i--) {
    p= apis[i].parent;
    if (p.itemLayer.name == layerName) {
        p.nonprinting = true; //change true to false to undo
    }
}

 

 

Peter Kahrel
Community Expert
Community Expert
November 10, 2022

Here you go. Setting nonprinting is as much/little effort as moving the rectangles to a particular layer.

 

 in a particular layer

 

In the script's text, replace xyz with the name of your layer.

r = app.documents[0].rectangles.everyItem().getElements();
for (i = r.length-1; i >= 0; i--) {
  if (r[i].itemLayer.name === 'xyz') {
    r[i].nonprinting = true;
  }
}

 

 

brian_p_dts
Community Expert
Community Expert
November 10, 2022

Beat me to the punch, @Peter Kahrel! But perhaps some are anchored. allGraphics.parent might be more efficient than allPageItems though in my example (and accounts for graphics not in rectangles)

Peter Kahrel
Community Expert
Community Expert
November 10, 2022

But perhaps some are anchored

True. Hadn't thought of that.