Copy link to clipboard
Copied
I had so much success with my 1st post (question) Thanks @rob day Next question. Have a text box at top of page that is the document version. For proofing to client, I need this to print so client can see what version they are looking at. But when printing the live print I need to make this texy box non-printing. Looking for a script that can make text box non-print. I have tried this script:
document.textFrames.item("version").nonprinting = true;
I have the text box labeled using script label as “version” (with no quotes).
I am getting below error:
I also tried the below script:
var version = doc.textFrames.itemByName("version");
version.nonprinting = true;
Getting this error:
Again Thanks VERY MUCH for all help and comments!
Copy link to clipboard
Copied
Are you sure you really do have a text frame named "version"? Your second script does work for me, unless I'm using a non-existent name, in which case it returns the same "Object is invalid" error.
Copy link to clipboard
Copied
I am no expert but I am about 95% sure Text box is labeled version.
Copy link to clipboard
Copied
I am no expert but I am about 95% sure Text box is labeled version
By @WCMProduction
As @Robert at ID-Tasker has already mentioned, then you need to check the label property of your text frames. In your original post, I missed that you were using Script Label (sorry!), I thought that "version" was the name assigned in the Layers panel.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks for input, but there are no other script labels in Doc.
Copy link to clipboard
Copied
Thanks for input, but there are no other script labels in Doc.
By @WCMProduction
Then it would be best if you iterate through all TFs - or only for a particular layer - and check "label" property.
Copy link to clipboard
Copied
I don’t think you can avoid the loop. This doesn’t throw an error, but the returned textFrame object has no properties:
var ver = app.activeDocument.textFrames.item("version")
$.writeln(ver) //returns [object TextFrame] but with no properties
Copy link to clipboard
Copied
Hi @WCMProduction , As @Robert at ID-Tasker suggests I thnk you will have to loop through the textFrames—.getElements() converts the Collection into an Array.
var ver = app.activeDocument.textFrames.everyItem().getElements();
for (var i = 0; i < ver.length; i++){
ver[i].nonprinting = true;
};
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hope this helps - run it again it switches it off and on
var doc = app.activeDocument;
var frames = doc.textFrames.everyItem().getElements();
for (var i = 0; i < frames.length; i++) {
if (frames[i].label === "version") {
frames[i].nonprinting = !frames[i].nonprinting;
alert("Text frame with script label 'version' is now set to " + (frames[i].nonprinting ? "non-printing." : "printing."));
break;
}
}
Copy link to clipboard
Copied
Overall, instead of switching this one property for each TextFrame with the label - move them ONCE to a layer - then it will be a single click on the Layers pallet...
Copy link to clipboard
Copied
As you're a Windows user - would you like to try full version of my tool for a few days?
You can sort & filter by any of the 1000+ object properties, or you can find TextFrames by their (partial) contents abd / or text properties - 400+.
Then, if you need to do more - you can export PDF/JPEG/ePUB/etc. file(s).
So, if your workflow requires turning on/off visibility of some objects / layers and then export PDF(s) - you can have it done with one click.
Or you can process in bulk whole folder with subfolders - of course, you can filter files first as well 😉
And if you don't need to export after creating / editing each document - you want to save time - you can edit them first and then export PDF(s) later in bulk - during a lunch break 😉
Exporting to a designated folder included.
Copy link to clipboard
Copied
Hi @WCMProduction ,
in your specific case I would avoid the Script Label panel.
Instead I would simply name the text frame "version". Either do this using the Layers panel or by scripting when the text frame is selected:
app.selection[0].name = "version";
Then your code will work as expected:
app.documents[0].textFrames.itemByName("version").nonprinting = true ;
Regards,
Uwe Laubender
( Adobe Community Expert )
Find more inspiration, events, and resources on the new Adobe Community
Explore Now