
Copy link to clipboard
Copied
Hi, i was hoping it was possible to create a script to reduce all fonts in a given document down a point size (example: a heading at 16pt and a paragraph text at 12pt would then become 15pt and 11pt respectivly). I ask because I have a document and paragraph styles have not been used!! So is this possible and if so could anyone help with coming up with a relevant script? It also has to be able to work within tables!
Many Thanks
Rob
1 Correct answer
This will change the point size and leading of every textRange in every story and table in the active document by -0.5 points.
...var changePointSize = -0.5;
var changeLeading = -0.5;
var myTexts = app.activeDocument.stories.everyItem().textStyleRanges.everyItem().getElements();
myTexts = myTexts.concat(app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().textStyleRanges.everyItem().getElements());
var newLeading, newPointSize;
for (var n=myTexts.length-1; n>=0; n--){
newPointS
Copy link to clipboard
Copied
If all the text is in one story this can be done without a script. Press Ctrl+Enter for quick apply and then type decrease and choose decrease font size (there is a keyboard shortcut for this, I just don't remember it). You can adjust how much it decreases by going to Edit-Prefernces-Units and Increments.
Copy link to clipboard
Copied
You can use the InDesign built-in SEARCH AND REPLACE command. It allow you to search any fonts and size, and replace with tour new settings.

Copy link to clipboard
Copied
Thanks giys, to answer the first question, no, the document is split up into various stories and tabular data so the quick search function will not do here.
I will try the SEARCH AND REPLACE, although is there not a way a script could be created for the initial question, i.e regardless of the particular font used reducing ALL fonts in that document by 1pt etc. I had seen a script to do such a thing but that was reducing all document font's by a percentage which is not practical.
Again thanks for your help so far, much appreciated

Copy link to clipboard
Copied
This may or may not help (it's not my script). Go to this web page:
http://www.adobe.com/cfusion/exchange/index.cfm?event=authorExtensions&authorid=83085907
Download the "Resize selected text" script. It only works on selected text (you can either select the text itself or the text frame).

Copy link to clipboard
Copied
Cheers Tom, thats more on the lines of what I'm after.
I'm still wondering whether its possible to run a script to reduce all font size and leading size by 1pt etc, in a document which has numerous stories and tabular data etc?
Rob

Copy link to clipboard
Copied
Is there anyway to adjust the following script so that I don't have to select the text before adjusting the size, i.e. once the script is activated it'l ask what size you want to adjust the text too in the whole document. This way I can adust the font sizes by 0.5pt in the whole document without selecting each and every story and tables.
var the_document = app.documents.item(0);
var the_selection = app.selection[0];
var the_dialog = app.dialogs.add({name:"Resize selected text"});
with(the_dialog.dialogColumns.add()){
with(dialogRows.add()){
staticTexts.add({staticLabel:"Resize the selected text by"});
var increase_by = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS, editValue:0});
}
}
the_dialog.show();
counter = 0;
do {
var current_character = the_selection.characters.item(counter);
current_character.pointSize = current_character.pointSize + increase_by.editValue;
counter++;
} while (counter < the_selection.characters.length);
alert("Done!");
Copy link to clipboard
Copied
You might try
var the_selection = app.textFrames.everyItem()

Copy link to clipboard
Copied
Hi Larry,
This did not seem to work, it returned the error:
Copy link to clipboard
Copied
I forgot to include the document. The app doesn't have text frames but the document does.
Copy link to clipboard
Copied
HI Rob
Try below code
add ur style name and point size
HI
var myDoc = app.activeDocument;
var myStyleNameList = new Array;
for(var a=0;a<myDoc.allParagraphStyles.length;a++){
if(app.activeDocument.paragraphStyles.item(a).name != "[No paragraph style]")
{
myStyleNameList.push(app.activeDocument.paragraphStyles.item(a).name);
}
if (app.activeDocument.paragraphStyles.item(a).name =="a")
{
myDoc.paragraphStyles.pointSize = 15;
}
}

Copy link to clipboard
Copied
Hi Mi_D,
Thanks for your script, however the indesign document I'm going to be working on will not have styles applied to it, thus i cannot add a style name to the script
Do you have any other suggestions?

Copy link to clipboard
Copied
Just found this script on the adobe site which does the job.
var myDocument = app.documents.item(0);
//Clear the find/change preferences.
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeTextOptions.caseSensitive = false;
app.findChangeTextOptions.includeFootnotes = false;
app.findChangeTextOptions.includeHiddenLayers = false;
app.findChangeTextOptions.includeLockedLayersForFind = false;
app.findChangeTextOptions.includeLockedStoriesForFind = false;
app.findChangeTextOptions.includeMasterPages = false;
app.findChangeTextOptions.wholeWord = false;
//Search the document for the 12 point text and change it to 11 point text.
app.findTextPreferences.pointSize = 12;
app.changeTextPreferences.pointSize = 11;
myDocument.changeText();
//Clear the find/change preferences after the search.
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
However it means i have to enter in the text values from within the script (highlighted above). Could an alert window be used so that when i run the script i can enter the findTextPreferences.pointSize (eg. 10 pt) and then enter the changeTextPreferences.pointSize (eg. 9 pt) whilst the script has been activated, here's my example of the pop up window i'm trying to explain (excuse my photoshop skills!):
Or an even better script, would be regardless of the current text pt size (whether it be 12pt 14pt or 8pt) and reduce all txt sizes by a certain pt size....Its just so a user can literally click a and change all text sizes by a pt size at the click of a button.
Hope im getting my point across, other than that i'll just use the find and change.
Copy link to clipboard
Copied
Hello Bob,
Please use below code for the same.
function show_window () {
w = new Window ("dialog", "Text Resize");
w.orientation = "row";
w.alignChildren = "top";
g1 = w.add("group");
p = g1.add("panel");
g2 = p.add("group");
g2.add("statictext", [0,0,100,25], "Current pt size:");
var find = g2.add("edittext {text: '12', characters: 8, justify: 'center'}")
find.active = true;
g2.add("statictext", undefined, "pt");
g3 = p.add("group");
g3.add("statictext", [0,0,100,25], "Change to:");
var change = g3.add("edittext {text: '11', characters: 8, justify: 'center'}")
g3.add("statictext", undefined, "pt");
g4 = w.add("group");
g4.orientation = "column";
g4.add("button", [0,0,85,25], "OK")
g4.add("button", [0,0,85,25], "Cancel")
if(w.show() == true){
find_change (find.text, change.text);
}
}
function find_change (find, change) {
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.pointSize = find;
app.changeGrepPreferences.pointSize = change;
doc.changeGrep(true);
app.findGrepPreferences = app.changeGrepPreferences = null;
}
if(app.documents.length>0){
var doc = app.activeDocument;
show_window ()
}else{
alert("Please open your document.");
exit(0);
}
Sumit

Copy link to clipboard
Copied
This will change the point size and leading of every textRange in every story and table in the active document by -0.5 points.
var changePointSize = -0.5;
var changeLeading = -0.5;
var myTexts = app.activeDocument.stories.everyItem().textStyleRanges.everyItem().getElements();
myTexts = myTexts.concat(app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().textStyleRanges.everyItem().getElements());
var newLeading, newPointSize;
for (var n=myTexts.length-1; n>=0; n--){
newPointSize = myTexts.pointSize+changePointSize;
newLeading = myTexts.leading+changeLeading;
myTexts.pointSize = (newPointSize>0)? newPointSize: myTexts .pointSize;
myTexts.leading = (newLeading>0&&myTexts .leading!=Leading.AUTO)? newLeading: myTexts .leading;
}
Copy link to clipboard
Copied
The Script Haakenlid wrote works fine for me - as long as there are tables in the document.
Can someone point me to a way to use this script also with documents with may not contain tables?
The approach from Oriup is also nice, as my scripting knowledge increase i will try to cobine both of them so that the paragraph formats match the actual changes (if the text isnt modified).
Copy link to clipboard
Copied
Hi,
one could do several things:
1. Add a single table to the document before running the script. 🙂
2. A quick fix of the script with a try/catch do nothing of line 4:
var changePointSize = -0.5;
var changeLeading = -0.5;
var myTexts = app.activeDocument.stories.everyItem().textStyleRanges.everyItem().getElements();
try{
myTexts = myTexts.concat(app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().textStyleRanges.everyItem().getElements());
}catch(e){};
var newLeading, newPointSize;
for (var n=myTexts.length-1; n>=0; n--){
newPointSize = myTexts
.pointSize+changePointSize; newLeading = myTexts
.leading+changeLeading; myTexts
.pointSize = (newPointSize>0)? newPointSize: myTexts .pointSize; myTexts
.leading = (newLeading>0&&myTexts .leading!=Leading.AUTO)? newLeading: myTexts .leading; }
BTW: The script would not catch
1. Text in tables that are nested in table cells.
2. Text in footnotes
Regards,
Uwe
Copy link to clipboard
Copied
I have edited Haakenlid script.
My script change point size in all Paragraph style.
Here is my version:
var changePointSize = 1;
var changeLeading = 2;
var myPStyle = app.activeDocument.allParagraphStyles;
var newLeading, newPointSize;
for (var i=1; i<myPStyle.length; i++){
newPointSize = myPStyle.pointSize+changePointSize;
newLeading = myPStyle.leading+changeLeading;
myPStyle.pointSize = (newPointSize>0)? newPointSize: myPStyle.pointSize;
myPStyle.leading = (newLeading>0&&myPStyle.leading!=Leading.AUTO)? newLeading: myPStyle.leading;
}
Sumit

