Copy link to clipboard
Copied
Good question today in InDesignSecrets.com, seeking assistance with a missing CC feature that was present pre-CC. Can anyone here help?
Here's the use case and question...
"I love using Page Color Labels. When I make a 100+ page catalog, and there are corrections on only about 10 pages throughout the document, I run through, make the changes, and flag the page with a change on it with a page color.
The old UI on InDesign for Mac (before CC) let you scroll through the Pages Panel whilst in the Export… dialog box. Now it’s locked stationary, inaccessible while the dialog is open. So now I either have to write down which pages have changed to them on a piece of paper, or remember before I choose File > Export.
I wish there was a script or a feature to somehow export all pages marked with a particular color label. Has anyone done this? I’d love to be pointed in the right direction if so."
(this was posted as a comment to an old post about color labels: http://indesignsecrets.com/keep-your-pages-in-order-with-color-labels.php )
Thanks for any help!
AM
Uwe, why copy/paste?
Here is my first idea, also a vers. 01 😉
If a color is applied from a master page, this is not honored at the moment. Page ranges are insert separatly and not as ranges at the moment. I could imagine, that we spent a dialog, where the user can choose a printer preset and the color to search …
...main();
function main() {
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if (!app.documents.length) {
alert ("No document open!");
exit();
}
var theFolde
Copy link to clipboard
Copied
Hi Anne-Marie,
Nice to see you here. I have the feeling Marijan did some thing in that area. You may want to get in touch with him.
FWIW
Loïc
Copy link to clipboard
Copied
Thanks Loic!
As far as I can tell Marijan has "left the building." His site has been gone for over a year now I think. His scripts are inaccessible.
But, I'll try asking him on FB.
AM
Copy link to clipboard
Copied
I have regular contact with through gtalk. I will ask him for this.
Copy link to clipboard
Copied
Hi AM,
here a quick shot, a first version 0.1 draft of a script, that will read out the used page colors and gives a scrollable alert where one can copy/paste the ranges of pages by page color to the input fields of InDesign's Print and Export menus.
The pages are listed in absolute numbers.
IMPORTANT NOTES:
The script is not perfect.
1. If a page's applied master is itself based on a master, the listed range will be WRONG and is showing the page color as: "USE_MASTER_COLOR".
2. The alert is scrollable if the list is growing very large, but you have to close the list, if you want to show InDesign's Export or Print dialog.
So one has to start the script and copy the page ranges to the clipboard before exporting or printing.
3. The names of the page colors are not presented in locale form, but in ExtendScript "programming speak":
"Light Blue" is presented as "LIGHT_BLUE".
"Hellbraun" in my German version will be "TAN" in the list.
Here the script code in ExtendScript (JavaScript):
I EDITED THE CODE IN THIS POST.
// List absolute numbers of pages by page color.jsx
// Uwe Laubender
// Draft 1
// Version 0.1
/**
* @@@BUILDINFO@@@ List absolute numbers of pages by page color.jsx !Version! Mon Jun 27 2016 13:36:43 GMT+0200
*/
/*
Published at Adobe InDesign Scripting Forum:
"Script to export labelled pages to PDF?"
AnneMarie Concepcion Jun 26, 2016
https://forums.adobe.com/thread/2173129
*/
main();
function main()
{
if(app.documents.length == 0){return};
var doc = app.documents[0];
var pagesArray = doc.pages.everyItem().getElements();
var pageColorArray = doc.pages.everyItem().pageColor;
var resultArray = [];
var resultString = "";
for(var n=0;n<pagesArray.length;n++)
{
var absoluteNumberAsString = "+"+ ( pagesArray
.documentOffset + 1 );
var pageColorString = pagesArray
.pageColor.toString();
if(pagesArray
.appliedMaster == null && pageColorString == "USE_MASTER_COLOR") {
pageColorString = "NOTHING";
}
else
{
if
(
pageColorString == "USE_MASTER_COLOR" &&
pagesArray
.appliedMaster.pageColor.toString() == "USE_MASTER_COLOR" && pagesArray
.appliedMaster.appliedMaster == null )
{
pageColorString = "NOTHING";
}
if
(
pageColorString == "USE_MASTER_COLOR" &&
pagesArray
.appliedMaster.pageColor.toString() != "USE_MASTER_COLOR" )
{
pageColorString = pagesArray
.appliedMaster.pageColor.toString(); }
};
if(resultArray[pageColorString] == undefined)
{
resultArray[pageColorString] = absoluteNumberAsString;
}
else
{
resultArray[pageColorString] = resultArray[pageColorString] +","+absoluteNumberAsString;
}
}
for(var x in resultArray)
{
resultString = resultString +"\r"+x+":"+"\r"+resultArray
+"\r"; };
var contentsOfAlert = "USAGE: Copy/paste the absolute page names listed here to your print or export menu."+"\r"+
"(Note: Applied masters based on masters will result in wrong ranges.)"+"\r"+
resultString;
scrollableAlert( "List absolute numbers of pages by page color | Version 0.1 | SCRIPT | Uwe Laubender" , contentsOfAlert);
function scrollableAlert( /*String*/ titleOfAlert , /*String*/ contentsOfAlert )
{
var w = new Window("dialog" , titleOfAlert );
var editTextList = w.add("edittext", undefined , contentsOfAlert , {multiline : true , scrolling : true });
editTextList.maximumSize.height = w.maximumSize.height-200;
editTextList.minimumSize.width = 600;
w.add("button", undefined, "Close" , {name : "ok"});
w.show();
}
};
Below a screenshots from my German InDesign after running the script. It is showing a scrollable alert with selectable text.
You cannot see a scroll bar, because the contents of the alert will not extend the maximum height of its UI.
1. Select a range of pages in absolute notation.
2. Copy the selection to the clipboard.
3. Close the scrollable alert.
4. Paste the contents of the clipboard to InDesign's PDF-Export dialog or to the Print dialog.
InDesign's PDF-Export dialog showing absolute numbers:
Tested with OSX 10.10.3 and InDesign CC 2015.4.
Not tested on Windows.
Cheers,
Uwe
Copy link to clipboard
Copied
Uwe, why copy/paste?
Here is my first idea, also a vers. 01 😉
If a color is applied from a master page, this is not honored at the moment. Page ranges are insert separatly and not as ranges at the moment. I could imagine, that we spent a dialog, where the user can choose a printer preset and the color to search …
main();
function main() {
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if (!app.documents.length) {
alert ("No document open!");
exit();
}
var theFolder = Folder.selectDialog("Choose a folder for export");
if (theFolder == null) {
exit();
}
var curDoc = app.documents[0];
var allPages = curDoc.pages;
var pageList = [];
var labelColor = "RED";
for (var i = 0; i < allPages.length; i++) {
var curPage = allPages;
var pColor = curPage.pageColor;
var pageNumb = curPage.documentOffset + 1;
if (pColor.toString() == labelColor) {
pageList.push("+" + pageNumb);
}
}
app.pdfExportPreferences.pageRange = pageList.join(",");
var pdfName = curDoc.name.replace(/.indd$/,".pdf");
var theFile = File(theFolder + "/" + pdfName);
try {
curDoc.exportFile(ExportFormat.PDF_TYPE , theFile , true);
}
catch(e) {
alert(e);
}
app.pdfExportPreferences.pageRange = "";
}
Kai
Copy link to clipboard
Copied
Thanks Kai, that's working fine here.
So if they use a different color, they just edit the script?
AM
Copy link to clipboard
Copied
AnneMarie Concepcion wrote:
… So if they use a different color, they just edit the script?…
Yes.
But the problem is knowing or guessing the right color name.
Just an example:
"Light Blue" is represented as "LIGHT_BLUE" in the scripting document object model (DOM) for ExtendScript.
So you cannot edit the script to "Light Blue" and hope for the best.
That would not work.
For German or any other Non-English version users it's even more complicated.
See the following screenshot from my German InDesign and the available colors for page colors:
@klippCW – FWIW, in the meanwhile my first draft "evolved" a bit.
With a function that will translate all possible options for colorPage values to localized strings.
What I did not tackle is the problem of deeper nested master spreads (masters based on masters based on masters etc.pp.).
However: Pages that get the page color from masters that are not based on masters are working well.
Also pages where the "None" master is applied and no "local" page color is directly applied to the page.
Here a screenshot from my German InDesign on a German Mac OSX with the localized strings presented in the scrollable alert:
How to save ExtendScript code and using scripts?
Copy/paste the code to a text-only file (no formatting!) and save the file with the suffix *.jsx.
Where to put the file?
Open InDesign's Scripts Panel and follow the steps outlined here:
Indiscripts :: Indiscripts for Dummies
Uwe
Copy link to clipboard
Copied
@klippCW: My script assumes, that you have your document pages local labeled with a color "RED". If you start the script, you will prompt with a dialog and must choose a folder for your PDF. After that, the script will collect all document page names with the applied label, call the export dialog and insert the right page numbers.
Your step is then to choose the right preset, nothing more.
As Uwe mentioned, both scripts are v01. So there is a need to find solutions for a handling of applied labels with a masterpage (in your case maybe not realy important) and how to find the right color. My idea is here, to collect every color from the page, exclude "USE_MASTER_COLOR" (for the moment) and let the user select the color from a dropdown.
So try both versions and give us feedback.
Kai
Copy link to clipboard
Copied
Hello again Kai
Thank you again for the amazing script, so far it works very well.
I have two feature requests.
1) When I use your script, I am allowed to choose a folder, but I cannot choose how to name my file. Can you add that type of dialog into the Export feature of your script? My goal is to be able to customize the name (to indicate it's a partial page selection export, and not the entire document), and export my RED pages as their own PDF and name the file as such. Another idea!: Is it possible for your script to incorporate the selected RED page numbers into the file name? But not statically—I'd still like to be able to customize the name if necessary. So you could populate the text field in the Export to Folder dialog with something like "filename-pg-1-3-7-15.pdf", but then I could add my own text in there if necessary. (I suppose this first request is really two-in-one, sorry!)
2) You mentioned the possibility of being able to catch ANY page color (rather than only RED). Is that still possible? It's perfectly workable with using RED only, as I generally just choose a single color to act as a "flag" just to indicate changes, but if I decide that I want to use different colors for different purposes, I might still like to include those colors all together in a single range.
If you are able and have time, maybe you could add my first requests about naming the file (#1), then share that script. Then you could make a second version with the added option of catching ANY color page. I say this because it might be handy to use a script that only catches a single color from time to time, but then other times it might be helpful to catch ALL colors.
Thank you so much!
PS—Laubender​, yours accomplishes my second request pretty well, but wondering if we can skip the "copy/paste" idea and push the numbers right into the range-window. I DO like however, Laubender, that I can actually EDIT in that text window you created, and I can copy/paste within your script's window to create a custom range of varying colors, on a per-usage basis. That is a very nice feature!
Copy link to clipboard
Copied
Sorry to revive such an old thread, but another answer has presented itself. A design agency has made a script available that will do what you're after: Export selected pages to pdf
Copy link to clipboard
Copied
Kai!
I'm very sorry it's been so long since you all so wonderfully contributed to my need of an exporter that uses Page Color Labels.
I finally had an instance again (and I now understand a little more about how to save/use scripts) that I got to try out your solution.
It works great!
It appears, from what I can tell, that it requires me to use the RED label only, and that if I want to change it, that I need to know how the CODE inside of InDesign "labels" that color (the UI shows "Red" but the code must be written as "RED"). Is that correct?
Thanks very much!
Also Laubender​, your script works VERY well too. Really excited to put both of these to use, and I'll keep you posted if I run into any issues or suggestions to it.
Copy link to clipboard
Copied
Uwe, not behind the 'good' computer so I cannot verify how hard it is, but:
1. Why not first build a dropdown list, and populate it with the current document's Page Colors
2. Then, after you get a selection from the user and gathering the page numbers, you can use
app.pdfExportPreferences.pageRange = yourPageString ;
to paste the range into the current PDF export box, and (oddly enough)
app.activeDocument.printPreferences.pageRange = yourPageString ;
for the print dialog box.
Copy link to clipboard
Copied
Hi,
well I wanted:
To show the user a big oversight of all used page ranges where one could copy parts of the ranges as well.
More control for the user. Hm. Maybe that's doable in ScriptUI as well.
But with much more effort on my side. 🙂
What woud be the right approach?
A scrollable list with checkboxes and the name of the color plus the range right to it?
Just a dropdown for the color and then automatically apply the page names in absolute notation?
Or a dropdown for the color plus the strings one can copy to the clipboard?
And as I said, the snippet is just a draft.
What should be done by the developers of InDesign:
Let the user scroll the Pages Panel while the PDF-Export dialog is open.
That feature went away after CS5.5 or CS6, I think. Have to check the exact version number, just tested CS 5.5.
Cheers,
Uwe
Copy link to clipboard
Copied
The feature scrolling the Pages Panel while the PDF-Export is open went away with InDesign CC v9.0.0.
You can hover over the controls of the panel and the controls are reacting a bit to the hover as if they can be activated, but you cannot click them active. And scrolling is not available as well. That's a bug that should be fixed.
Uwe
Copy link to clipboard
Copied
Thank you all for the help! I linked to this discussion in a new comment in the InDesignSecrets.com post.
AM
Copy link to clipboard
Copied
Hello scripting friends! I was the one who initially posted on InDesignSecrets who wanted to page range of my pages with colors.
It seems that Uwe has a more approachable solution to my needs, though I haven't tried it yet. Do I just copy/paste this into a text editor and save as .jsx and throw in the scripts folder?
Also, I'm interested in all the things Kai was suggesting but it frankly went way over my head. Any tangible examples you can provide of how yours works (screen shots?) Or is all your code and ideas about drop downs, etc all hypothetical?
THANK YOU for all the amazing, fast work you did on coming up with clever ideas. I'm happy to try/use anyone's ideas, I just have to understand (as a non-developer) what my responsibility is when I acquire the code (do I have to edit anything? save it a particular way? I've also never posted in this scripting community, so I'm not sure if I can react to a bug in this thread and ask for a correction?)
Thanks so much everyone