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

How to toggle Printing/Non Printing for graphic objects

Explorer ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

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.

TOPICS
EPUB , How to , Import and export , Performance , Print , Publish online , Scripting

Views

82

Likes

Translate

Translate

Report

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 ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

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

 

 

Likes

Translate

Translate

Report

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 ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

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)

Likes

Translate

Translate

Report

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 ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

But perhaps some are anchored

True. Hadn't thought of that.

Likes

Translate

Translate

Report

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 ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

 

 

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
    }
}

 

 

Likes

Translate

Translate

Report

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 ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

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

EugeneTyson_0-1668106051543.png

 

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. 

Likes

Translate

Translate

Report

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 ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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 ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

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

 

P.

Likes

Translate

Translate

Report

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 ,
Nov 11, 2022 Nov 11, 2022

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

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