├── Add Page Border.jsx ├── Count Selected Items.jsx ├── Count Text.jsx ├── Create Guides Around Container.jsx ├── Detail Typesetting.jsx ├── Export List of Graphics.jsx ├── LICENSE.md ├── README.md ├── Resize Selected Items.jsx ├── Shuffle Page Items.jsx └── Shuffle Page Order.jsx /Add Page Border.jsx: -------------------------------------------------------------------------------- 1 | // 2 | // Add Page Border 3 | // v 0.1 4 | // by John Pobojewski, 2014 5 | // based on work by Cari Jansen www.carijansen.com 2005 6 | // 7 | // Adds a page border on every master page on a separate FPO layer 8 | // 9 | 10 | app.doScript (main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Add Page Border"); 11 | 12 | function main(){ 13 | getDialog(); 14 | } 15 | 16 | function getDialog(){ 17 | var _doc = app.activeDocument; 18 | var Dialog; 19 | 20 | with(Dialog = app.dialogs.add({name: "Add Page Border"})){ 21 | with(dialogColumns.add()){ 22 | with(borderPanels.add()){ 23 | with(dialogColumns.add()){ 24 | with(dialogRows.add()){ 25 | staticTexts.add({staticLabel:"Stroke Weight:", minWidth: 50}); 26 | var _strokeWeight = measurementEditboxes.add({editValue: 0.3, editUnits:MeasurementUnits.points, minWidth:100}); 27 | } 28 | with(dialogRows.add()){ 29 | staticTexts.add({staticLabel:"Stroke Type:", minWidth: 50}); 30 | var strokeStyleList = []; 31 | for (var i=0; i<_doc.strokeStyles.length; i++){ 32 | strokeStyleList.push(_doc.strokeStyles.item(i).name); 33 | } 34 | var defaultStrokeIndex = _doc.strokeStyles.item("Solid").index; 35 | var _strokeStyleMenu = dropdowns.add({stringList:strokeStyleList, selectedIndex:defaultStrokeIndex, minWidth: 100}); 36 | } 37 | with(dialogRows.add()){ 38 | staticTexts.add({staticLabel:"Stroke Color:", minWidth: 50}); 39 | var colorList = []; 40 | for (var i=0; i<_doc.swatches.length; i++){ 41 | colorList.push(_doc.swatches.item(i).name); 42 | } 43 | var defaultSwatchIndex = _doc.swatches.item("Black").index; 44 | var _colorMenu = dropdowns.add({stringList:colorList, selectedIndex:defaultSwatchIndex, minWidth: 100}); 45 | } 46 | } 47 | } 48 | } 49 | } 50 | myResult = Dialog.show(); 51 | if (myResult == true){ 52 | 53 | 54 | var strokeColor = _doc.swatches.item("Black"); 55 | var noColor = _doc.swatches.item("None"); 56 | var strokeType = _doc.strokeStyles.item("Solid"); 57 | var strokeLayer = _doc.layers.item("Page Border"); 58 | 59 | // add stroke layer 60 | if (strokeLayer == null){ 61 | strokeLayer = _doc.layers.add(); 62 | strokeLayer.move(LocationOptions.atBeginning, undefined); 63 | strokeLayer.name = "Page Border"; 64 | } else { 65 | // unlock it 66 | strokeLayer.locked = false; 67 | } 68 | 69 | // include it on every master page 70 | for (var i=0; i<_doc.masterSpreads.length; i++){ 71 | for (var j=0; j<_doc.masterSpreads[i].pages.length; j++){ 72 | var _pg = _doc.masterSpreads[i].pages.item(j); 73 | var _border = _pg.rectangles.add(); 74 | _border.itemLayer = strokeLayer; 75 | _border.geometricBounds = _pg.bounds; 76 | 77 | _border.strokeWeight = parseFloat(_strokeWeight.editContents); // in points 78 | _border.strokeType = _doc.strokeStyles.item( _strokeStyleMenu.stringList[_strokeStyleMenu.selectedIndex] ); 79 | _border.strokeColor = _doc.swatches.item( _colorMenu.stringList[_colorMenu.selectedIndex] ); 80 | _border.strokeTint = 100; // in % 81 | 82 | _border.fillColor = noColor; 83 | _border.strokeAlignment = StrokeAlignment.insideAlignment; 84 | } 85 | } 86 | 87 | // lock the made layer 88 | strokeLayer.locked = true; 89 | 90 | //Remove the dialog from memory. 91 | Dialog.destroy(); 92 | 93 | alert("Complete!"); 94 | } 95 | else{ 96 | //Remove the dialog from memory. 97 | Dialog.destroy(); 98 | } 99 | } -------------------------------------------------------------------------------- /Count Selected Items.jsx: -------------------------------------------------------------------------------- 1 | // 2 | // Count Selected Items 3 | // v 1.5 4 | // by John Pobojewski 5 | // 6 | // Counts items that are selected and alerts result 7 | // 8 | 9 | 10 | app.doScript (main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Count Selected Items"); 11 | 12 | function main(){ 13 | //Make certain that user interaction (display of dialogs, etc.) is turned on. 14 | app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; 15 | if (app.documents.length != 0){ 16 | if (app.activeWindow.activeSpread.pageItems.length != 0){ 17 | run(); 18 | } 19 | else { 20 | alert("The active spread does not contain any page items."); 21 | } 22 | } 23 | else{ 24 | alert("No documents are open. Please open a document and try again."); 25 | } 26 | } 27 | 28 | function run(){ 29 | 30 | var _doc = app.activeDocument; 31 | var _sel = app.selection; 32 | 33 | if (_sel.length > 0){ 34 | var myDialog = app.dialogs.add({name:"Count Selected Items", canCancel:false}); 35 | with(myDialog){ 36 | //Add a dialog column. 37 | with(dialogColumns.add()){ 38 | with(borderPanels.add()){ 39 | staticTexts.add({staticLabel:"You have "}); 40 | with(dialogColumns.add()){ 41 | textEditboxes.add({editContents:_sel.length+""}); 42 | } 43 | with(dialogColumns.add()){ 44 | staticTexts.add({staticLabel:" items selected."}); 45 | } 46 | } 47 | } 48 | } 49 | myDialog.show(); 50 | myDialog.destroy(); 51 | } else { 52 | alert("Please select some items to count."); 53 | } 54 | } -------------------------------------------------------------------------------- /Count Text.jsx: -------------------------------------------------------------------------------- 1 | //Count Text 2 | //Based on TextCounter.js: An InDesign 3 JavaScript 3 | // 4 | //Counts text objects in the selection, in the selected story, or in all stories in a document. 5 | // 6 | 7 | app.doScript (main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Count Text"); 8 | 9 | function main(){ 10 | if(app.documents.length != 0){ 11 | if(app.activeDocument.stories.length > 0){ 12 | myDisplayDialog(); 13 | } 14 | else{ 15 | alert("The current document does not contain any text."); 16 | } 17 | } 18 | else{ 19 | alert("No documents are open. Please open a document and try again."); 20 | } 21 | } 22 | 23 | function myDisplayDialog(){ 24 | var myCountButtons, myRangeButtons; 25 | var myDialog = app.dialogs.add({name:"Count Text"}); 26 | with(myDialog.dialogColumns.add()){ 27 | with(borderPanels.add()){ 28 | staticTexts.add({staticLabel:"Count:"}); 29 | with(myCountButtons = radiobuttonGroups.add()){ 30 | radiobuttonControls.add({staticLabel:"Characters"}); 31 | radiobuttonControls.add({staticLabel:"Words", checkedState:true}); 32 | radiobuttonControls.add({staticLabel:"Lines"}); 33 | radiobuttonControls.add({staticLabel:"Paragraphs"}); 34 | } 35 | } 36 | with(borderPanels.add()){ 37 | staticTexts.add({staticLabel:"Range:"}); 38 | with(myRangeButtons = radiobuttonGroups.add()){ 39 | radiobuttonControls.add({staticLabel:"Selection", checkedState:true}); 40 | radiobuttonControls.add({staticLabel:"Selected Story"}); 41 | radiobuttonControls.add({staticLabel:"All Stories"}); 42 | } 43 | } 44 | } 45 | var myReturn = myDialog.show(); 46 | if (myReturn == true){ 47 | //Get the values from the dialog box. 48 | var myRangeType = myRangeButtons.selectedButton; 49 | var myCountType = myCountButtons.selectedButton; 50 | myDialog.destroy(); 51 | myTextCounter(myRangeType, myCountType); 52 | } 53 | else{ 54 | myDialog.destroy(); 55 | } 56 | } 57 | function myTextCounter(myRangeType, myCountType){ 58 | var myDocument, myTextCount, mySelection, myCountingUnit; 59 | with (myDocument = app.activeDocument){ 60 | //Set the AlreadyCounted key of any stories in the document to false. 61 | for (var myStoryCounter = 0; myStoryCounter < myDocument.stories.length; myStoryCounter ++){ 62 | myDocument.stories.item(myStoryCounter).insertLabel("AlreadyCounted", "False") 63 | } 64 | switch (myRangeType){ 65 | case 0: 66 | //Count the text in the selection. 67 | //If multiple text frames are selected, all of the 68 | //text in the frames will be counted. 69 | mySelection = selection; 70 | if (mySelection.length == 1){ 71 | myTextCount = mySelectionSorter(mySelection[0], myRangeType, myCountType); 72 | } 73 | else{ 74 | myTextCount = 0; 75 | for (var myCounter = 0; myCounter < mySelection.length; myCounter++){ 76 | myTextCount = myTextCount + mySelectionSorter(mySelection[myCounter], myRangeType, myCountType); 77 | } 78 | } 79 | break; 80 | case 1: 81 | //Count the text in the parent story (or stories) of the selection) 82 | mySelection = selection; 83 | if (mySelection.length == 1){ 84 | myTextCount = mySelectionSorter(mySelection[0], myRangeType, myCountType); 85 | } 86 | else{ 87 | myTextCount = 0; 88 | //Now iterate through the items and count the text. 89 | for (var myCounter = 0; myCounter < mySelection.length; myCounter++){ 90 | myTextCount = myTextCount + mySelectionSorter(mySelection[myCounter], myRangeType, myCountType); 91 | } 92 | } 93 | break; 94 | case 2: 95 | //Count the text in all stories of the active document. 96 | myTextCount = 0; 97 | for(var myStoryCounter = 0; myStoryCounter < myDocument.stories.length; myStoryCounter ++){ 98 | myTextCount = myTextCount + myCountText(myDocument.stories.item(myStoryCounter), myCountType); 99 | } 100 | break; 101 | } 102 | switch(myCountType){ 103 | case 0: 104 | if (myTextCount == 1){ 105 | myCountingUnit = "character"; 106 | } 107 | else { 108 | myCountingUnit = "characters"; 109 | } 110 | break; 111 | case 1: 112 | if (myTextCount == 1){ 113 | myCountingUnit = "word"; 114 | } 115 | else { 116 | myCountingUnit = "words"; 117 | } 118 | break; 119 | case 2: 120 | if (myTextCount == 1){ 121 | myCountingUnit = "line"; 122 | } 123 | else { 124 | myCountingUnit = "lines"; 125 | } 126 | break; 127 | case 3: 128 | if (myTextCount == 1){ 129 | myCountingUnit = "paragraph"; 130 | } 131 | else { 132 | myCountingUnit = "paragraphs"; 133 | } 134 | break; 135 | } 136 | var myDialog = app.dialogs.add({name:"Count Text", canCancel:false}); 137 | with(myDialog){ 138 | //Add a dialog column. 139 | with(dialogColumns.add()){ 140 | with(borderPanels.add()){ 141 | staticTexts.add({staticLabel:"InDesign found "}); 142 | with(dialogColumns.add()){ 143 | textEditboxes.add({editContents:myTextCount+""}); 144 | } 145 | with(dialogColumns.add()){ 146 | staticTexts.add({staticLabel:myCountingUnit}); 147 | } 148 | } 149 | } 150 | } 151 | myDialog.show(); 152 | myDialog.destroy(); 153 | } 154 | } 155 | function mySelectionSorter(myObject, myRangeType, myCountType){ 156 | var myTextCount; 157 | switch (myObject.constructor.name){ 158 | case "Text": 159 | case "InsertionPoint": 160 | switch (myRangeType){ 161 | case 0: 162 | myTextCount = myCountText(myObject, myCountType); 163 | break; 164 | case 1: 165 | myTextCount = myCountText(myObject.parentStory, myCountType); 166 | break; 167 | } 168 | break; 169 | case "TextFrame": 170 | switch (myRangeType){ 171 | case 0: 172 | myTextCount = myCountText(myObject.texts.item(0), myCountType); 173 | break; 174 | case 1: 175 | //Has the parent story already been counted? 176 | myStory = myObject.parentStory; 177 | myCountedState = myStory.extractLabel("AlreadyCounted"); 178 | if (myCountedState != "True"){ 179 | myTextCount = myCountText(myStory, myCountType); 180 | myStory.insertLabel("AlreadyCounted", "True"); 181 | } 182 | else { 183 | myTextCount = 0; 184 | } 185 | break; 186 | } 187 | break; 188 | default: 189 | //Selection is a not a text object. 190 | //There's still a chance it could be a textPath object. 191 | if (myObject.textPaths.length !=0){ 192 | myTextCount = 0; 193 | if (myRangeType == 1){ 194 | for (myTextPathCounter = 0; myTextPathCounter < myObject.textPaths.length; myTextPathCounter ++){ 195 | myStory = myObject.textPaths.item(myTextPathCounter).parentStory; 196 | myCountedState = myStory.extractLabel("AlreadyCounted"); 197 | if (myCountedState != "True"){ 198 | myTextCount = myTextCount + myCountText(myObject.textPaths.item(myTextPathCounter).parentStory, myCountType); 199 | myObject.textPaths.item(myTextPathCounter).parentStory.insertLabel("AlreadyCounted","True"); 200 | } 201 | else{ 202 | myTextCount = 0; 203 | } 204 | } 205 | } 206 | else { 207 | for (myTextPathCounter = 0; myTextPathCounter < myObject.textPaths.length; myTextPathCounter ++){ 208 | myTextCount = myTextCount + myCountText(myObject.textPaths.item(myTextPathCounter).texts.item(0), myCountType); 209 | } 210 | } 211 | } 212 | else { 213 | myTextCount = 0; 214 | } 215 | break; 216 | } 217 | return myTextCount; 218 | } 219 | function myCountText(myTextObject, myCountType){ 220 | var myTextCount; 221 | switch(myCountType){ 222 | case 0: 223 | //count characters 224 | myTextCount = myTextObject.characters.length; 225 | break; 226 | case 1: 227 | //count words 228 | myTextCount = myTextObject.words.length; 229 | break; 230 | case 2: 231 | //count lines 232 | myTextCount = myTextObject.lines.length; 233 | break; 234 | case 3: 235 | //count paragraphs 236 | myTextCount = myTextObject.paragraphs.length; 237 | break; 238 | } 239 | return myTextCount; 240 | } -------------------------------------------------------------------------------- /Create Guides Around Container.jsx: -------------------------------------------------------------------------------- 1 | // 2 | // Create Guides Around Container 3 | // v 1.0 4 | // by John Pobojewski, 2009 5 | // 6 | // Plots guides within a selected shape's perimeter 7 | // 8 | 9 | app.doScript (main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Create Guides Around Container"); 10 | 11 | function main(){ 12 | var _doc = app.activeDocument; 13 | var _sel = app.selection; 14 | 15 | var numRows = 0; 16 | var numColumns = 0; 17 | var rowGutter = 0; 18 | var columnGutter = 0; 19 | var activeGuideColor = UIColors.gray; 20 | 21 | if (app.selection.length > 0){ 22 | if (app.selection.length == 1){ 23 | openDialog(); 24 | } else { 25 | alert("Please select only 1 perimeter object for the grid to be composed within and rerun the script." ); 26 | } 27 | } else { 28 | alert("Please select 1 perimeter object for the grid to be composed within and rerun the script." ); 29 | } 30 | } 31 | 32 | function drawGuidesAroundObject(){ 33 | // alert(numRows + '\n' + numColumns + '\n' + rowGutter + '\n' + columnGutter); 34 | var perimeter = app.selection[0]; 35 | var bounds = perimeter.geometricBounds; 36 | var gridX = bounds[1]; 37 | var gridY = bounds[0]; 38 | var gridWidth = bounds[3]-bounds[1]; 39 | var gridHeight = bounds[2]-bounds[0]; 40 | var rowHeight = (gridHeight - (rowGutter*(numRows-1)))/numRows; 41 | var columnWidth = (gridWidth - (columnGutter*(numColumns-1)))/numColumns; 42 | 43 | // draw rows 44 | var activeX = gridY; 45 | 46 | for (var i=0; i<=numRows; i++){ 47 | if (i == 0 || i == numRows){ 48 | var activeGutter = 0; 49 | drawGuide(activeX, 0); 50 | } else { 51 | activeGutter = rowGutter; 52 | drawGuide(activeX, 0); 53 | drawGuide(activeX + rowGutter, 0); 54 | }; 55 | activeX += activeGutter + rowHeight; 56 | }; 57 | 58 | // draw columns 59 | var activeY = gridX; 60 | for (var i=0; i<=numColumns; i++){ 61 | if (i == 0 || i == numColumns){ 62 | var activeGutter = 0; 63 | drawGuide(activeY, 1); 64 | } else { 65 | activeGutter = columnGutter; 66 | drawGuide(activeY, 1); 67 | drawGuide(activeY + columnGutter, 1); 68 | }; 69 | activeY += activeGutter + columnWidth; 70 | }; 71 | } 72 | 73 | function drawGuide(myGuideLocation, myGuideOrientation){ 74 | // alert(myGuideLocation); 75 | 76 | with(app.activeWindow.activePage){ 77 | //Place guides at the margins of the page. 78 | if(myGuideOrientation == 0){ 79 | guides.add(undefined, {orientation:HorizontalOrVertical.horizontal, location:myGuideLocation, guideColor:activeGuideColor}); 80 | } else { 81 | guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:myGuideLocation, guideColor:activeGuideColor}); 82 | } 83 | } 84 | } 85 | 86 | function openDialog(){; 87 | var dialog = app.dialogs.add({name:"Create Guides Around Container"}); 88 | var colorStrings = ["lightBlue", 89 | "red", 90 | "green", 91 | "blue", 92 | "yellow", 93 | "magenta", 94 | "cyan", 95 | "gray", 96 | "black", 97 | "orange", 98 | "darkGreen", 99 | "teal", 100 | "tan", 101 | "brown", 102 | "violet", 103 | "gold", 104 | "darkBlue", 105 | "pink", 106 | "lavender", 107 | "brickRed"]; 108 | 109 | with (dialog){ 110 | with(dialogColumns.add()){ 111 | with(dialogRows.add()){ 112 | with(dialogColumns.add()){ 113 | with(borderPanels.add()){ 114 | staticTexts.add({staticLabel:"Rows:", minWidth:60}); 115 | var numRowsBox = realEditboxes.add({editValue:1}); 116 | staticTexts.add({staticLabel:"Gutter:"}); 117 | var rowGutterBox = realEditboxes.add({editValue:0.125}); 118 | } 119 | } 120 | } 121 | with(dialogRows.add()){ 122 | with(dialogColumns.add()){ 123 | with(borderPanels.add()){ 124 | staticTexts.add({staticLabel:"Columns:"}); 125 | var numColumnsBox = realEditboxes.add({editValue:1}); 126 | staticTexts.add({staticLabel:"Gutter:"}); 127 | var columnGutterBox = realEditboxes.add({editValue:0.125}); 128 | } 129 | } 130 | } 131 | with(dialogRows.add()){ 132 | with(borderPanels.add()){ 133 | var colorMenu = dropdowns.add({stringList:colorStrings, selectedIndex:0, minWidth: 259}); 134 | } 135 | } 136 | } 137 | } 138 | var returned = dialog.show(); 139 | 140 | if (returned){ 141 | numRows = parseInt(numRowsBox.editContents); 142 | numColumns = parseInt(numColumnsBox.editContents); 143 | rowGutter = parseFloat(rowGutterBox.editContents); 144 | columnGutter = parseFloat(columnGutterBox.editContents); 145 | activeGuideColor = UIColors[colorMenu.stringList[colorMenu.selectedIndex]]; 146 | drawGuidesAroundObject(); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Detail Typesetting.jsx: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Detail Typesetting 4 | // v 2.0 5 | // by John Pobojewski, 2014 6 | // 7 | // Details text following the common rules of typesetting 8 | // 9 | 10 | app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Detail Typesetting"); 11 | 12 | function main(){ 13 | 14 | var CHECK_DOCUMENT = false; 15 | var CHECK_JUSTIFICATION = true; 16 | var CHECK_ENDASH = true; 17 | var CHECK_EMDASH = true; 18 | var CHECK_ELLIPSIS = true; 19 | var CHECK_TWOSPACES = true; 20 | var CHECK_MEASUREMENTS = true; 21 | var CHECK_MATH = true; 22 | 23 | getDialog(); 24 | } 25 | 26 | function getDialog(){ 27 | var Dialog; 28 | with(Dialog = app.dialogs.add({name:"Detail Typesetting"})){ 29 | with(dialogColumns.add()){ 30 | with(borderPanels.add()){ 31 | staticTexts.add({staticLabel:"Check:"}); 32 | var checkSettings = radiobuttonGroups.add(); 33 | with(checkSettings){ 34 | radiobuttonControls.add({staticLabel:"Selection", checkedState:true}); 35 | radiobuttonControls.add({staticLabel:"Document"}); 36 | } 37 | } 38 | with(borderPanels.add()){ 39 | with(dialogColumns.add()){ 40 | var checkJustification = checkboxControls.add({staticLabel:"Justification", checkedState:true}); 41 | var checkEnDash = checkboxControls.add({staticLabel:"En Dash", checkedState:true}); 42 | var checkEmDash = checkboxControls.add({staticLabel:"Em Dash", checkedState:true}); 43 | var checkEllipsis = checkboxControls.add({staticLabel:"Ellipsis", checkedState:true}); 44 | var checkTwoSpaces = checkboxControls.add({staticLabel:"Extra Space at End of Sentence", checkedState:true}); 45 | var checkMeasurements = checkboxControls.add({staticLabel:"Measurement Marks", checkedState:true}); 46 | var checkMath = checkboxControls.add({staticLabel:"Math Marks", checkedState:true}); 47 | } 48 | } 49 | } 50 | } 51 | myResult = Dialog.show(); 52 | if (myResult == true){ 53 | 54 | if (checkSettings.selectedButton == 0) CHECK_DOCUMENT = false; 55 | if (checkSettings.selectedButton == 1) CHECK_DOCUMENT = true; 56 | 57 | CHECK_JUSTIFICATION = checkJustification; 58 | CHECK_ENDASH = checkEnDash; 59 | CHECK_EMDASH = checkEmDash; 60 | CHECK_ELLIPSIS = checkEllipsis; 61 | CHECK_TWOSPACES = checkTwoSpaces; 62 | CHECK_MEASUREMENTS = checkMeasurements; 63 | CHECK_MATH = checkMath; 64 | 65 | //Reset the find/change preferences before each search. 66 | app.changeTextPreferences = NothingEnum.nothing; 67 | app.findTextPreferences = NothingEnum.nothing; 68 | 69 | if (CHECK_DOCUMENT){ 70 | checkDocument(); 71 | } else { 72 | checkSelection(); 73 | } 74 | grepPrimeMarks(); 75 | 76 | //Reset the find/change preferences before each search. 77 | app.changeTextPreferences = NothingEnum.nothing; 78 | app.findTextPreferences = NothingEnum.nothing; 79 | 80 | //Remove the dialog from memory. 81 | Dialog.destroy(); 82 | 83 | alert("Complete!"); 84 | } 85 | else{ 86 | //Remove the dialog from memory. 87 | Dialog.destroy(); 88 | } 89 | } 90 | 91 | function checkDocument(){ 92 | var _doc = app.activeDocument; 93 | 94 | for (var i=0; i<_doc.pages.length; i++){ 95 | var _pg = _doc.pages[i]; 96 | for (var j=0; j<_pg.textFrames.length; j++){ 97 | var s = _pg.textFrames[j].parentStory; 98 | 99 | s.contents = scrubTypographyInString(s.contents); 100 | 101 | for (var p=0; p 100 || currVScale > 100){ 67 | temp += ",*,"; 68 | } else { 69 | temp += ",,"; 70 | } 71 | 72 | var x_dim = Math.round(_graphics[aa].parent.geometricBounds[3]*100)/100; 73 | var y_dim = Math.round(_graphics[aa].parent.geometricBounds[0]*100)/100; 74 | 75 | if ( currHScale > 100 || currVScale > 100 || isNull){ 76 | temp += _graphics[aa].parentPage.name + "," + x_dim + " ," + y_dim; 77 | } else { 78 | temp += _graphics[aa].parentPage.name + "," + x_dim + " ," + y_dim; 79 | } 80 | 81 | temp += "," + _graphics[aa].effectivePpi + ","; 82 | temp += "\n"; 83 | } 84 | 85 | temp += "\n"; 86 | if (null_cnt > 0){ 87 | temp += "EMBEDDED: " + null_cnt + "\n"; 88 | } 89 | temp += "TOTAL: " + _graphics.length; 90 | 91 | myFolder = Folder.selectDialog ("Export Images List"); 92 | 93 | fn = app.activeDocument.name.split('.')[0] + "_links.csv"; 94 | fp = myFolder + "/" + fn; 95 | 96 | var graphicsFile = new File(fp); 97 | graphicsFile.open("w"); 98 | graphicsFile.write(temp); 99 | graphicsFile.close(); 100 | 101 | alert("Complete!"); 102 | } 103 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 John Pobojewski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | InDesign-Toolbox 2 | ================ 3 | 4 | A toolbox of short scripts. Tested in InDesign CC 2014 on Mac. 5 | 6 | Install in InDesign 7 | ---- 8 | 1. Go into the Window menu and choose Utilities > Scripts. 9 | 10 | 2. In the Scripts Panel you'll see Application and User folders. Click to select the User folder. 11 | 12 | 3. At the top right of the panel go into the menu and choose Reveal in Finder (Mac) or Reveal in Explorer (PC). 13 | 14 | 4. You should now see a Scripts Panel folder. Drag the script files/folder into there and it's installed. 15 | 16 | 5. Switch back to InDesign and the script will be listed under the folder you put it in. 17 | 18 | 6. To start the script just double-click it. 19 | -------------------------------------------------------------------------------- /Resize Selected Items.jsx: -------------------------------------------------------------------------------- 1 | // // Resize Selected Items // v 2.0 // by John Pobojewski // // Resizes a selection of multiple page items proportionally // app.doScript (main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Resize Selected Items"); function main(){ var _sel = app.selection; var w = 0; var h = 0; var origHU = app.activeDocument.viewPreferences.horizontalMeasurementUnits; var origVU = app.activeDocument.viewPreferences.verticalMeasurementUnits; var TRANSFORM_WIDTH = true; var TRANSFORM_HEIGHT = true; var WIDTH_IS_RELATIVE = false; var HEIGHT_IS_RELATIVE = false; app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points; app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points; if (_sel.length > 0){ var ARE_SAME_DIMENSIONS = true; for (var i=0; i<_sel.length; i++){ var obj = _sel[i]; var ow = obj.geometricBounds[3] - obj.geometricBounds[1] var oh = obj.geometricBounds[2] - obj.geometricBounds[0]; if (i > 0){ if (w != ow || h != oh) ARE_SAME_DIMENSIONS = false; } w = ow; h = oh; } getDialog(ARE_SAME_DIMENSIONS); } else { alert("Please select some items to resize."); } function getDialog(ASSIGN_DIMENSIONS){ var Dialog; //Create the SelectObjects dialog box. with(Dialog = app.dialogs.add({name:"Resize Items"})){ with(dialogColumns.add()){ with(borderPanels.add()){ with(dialogColumns.add()){ var transformWidth = checkboxControls.add({staticLabel:"Width:", checkedState:true}); if (ASSIGN_DIMENSIONS){ var widthBox = measurementEditboxes.add({editValue:w, editUnits:origHU}); } else { var widthBox = measurementEditboxes.add({editValue:0, editUnits:origVU}); } var widthIsRelative = checkboxControls.add({staticLabel:"Relative", checkedState:false}); } with(dialogColumns.add()){ var transformHeight = checkboxControls.add({staticLabel:"Height:", checkedState:true}); if (ASSIGN_DIMENSIONS){ var heightBox = measurementEditboxes.add({editValue:h, editUnits:origHU}); } else { var heightBox = measurementEditboxes.add({editValue:0, editUnits:origVU}); } var heightIsRelative = checkboxControls.add({staticLabel:"Relative", checkedState:false}); } } //staticTexts.add({staticLabel:"©2010 J Pobojewski", minWidth: 50}); } } myResult = Dialog.show(); if (myResult == true){ TRANSFORM_WIDTH = transformWidth.checkedState; TRANSFORM_HEIGHT = transformHeight.checkedState; WIDTH_IS_RELATIVE = widthIsRelative.checkedState; HEIGHT_IS_RELATIVE = heightIsRelative.checkedState; w = widthBox.editValue; h = heightBox.editValue; //Remove the dialog from memory. resizeItems(); Dialog.destroy(); } else{ //Remove the dialog from memory. Dialog.destroy(); } } function resizeItems(){ for (var i=0; i<_sel.length; i++){ var obj = _sel[i]; var anchor = app.activeWindow.transformReferencePoint; var ow = obj.geometricBounds[3] - obj.geometricBounds[1] var oh = obj.geometricBounds[2] - obj.geometricBounds[0]; if (TRANSFORM_WIDTH){ if (WIDTH_IS_RELATIVE){ var pw = (w + ow)/ow; } else { var pw = w/ow; } } else { var pw = 1.0; } if (TRANSFORM_HEIGHT){ if (HEIGHT_IS_RELATIVE){ var ph = (h + oh)/oh; } else { var ph = h/oh; } } else { var ph = 1.0; } var matrix = app.transformationMatrices.add({horizontalScaleFactor: pw, verticalScaleFactor: ph}); obj.transform(CoordinateSpaces.pasteboardCoordinates, anchor, matrix); } app.activeDocument.viewPreferences.horizontalMeasurementUnits = origHU; app.activeDocument.viewPreferences.verticalMeasurementUnits = origVU; } } -------------------------------------------------------------------------------- /Shuffle Page Items.jsx: -------------------------------------------------------------------------------- 1 | // 2 | // Shuffle Page Items 3 | // v 1.0 4 | // by John Pobojewski 5 | // 6 | // Randomly shuffles page items around 7 | // Note: will move and resize all items on page! 8 | // 9 | 10 | app.doScript (main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Shuffle Page Items"); 11 | 12 | function main(){ 13 | //Make certain that user interaction (display of dialogs, etc.) is turned on. 14 | app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; 15 | if (app.documents.length != 0){ 16 | if (app.activeWindow.activeSpread.pageItems.length != 0){ 17 | run(); 18 | } 19 | else { 20 | alert("The active spread does not contain any page items."); 21 | } 22 | } 23 | else{ 24 | alert("No documents are open. Please open a document and try again."); 25 | } 26 | } 27 | 28 | function run(){ 29 | var _sel = app.selection; 30 | 31 | // init counter 32 | var _pos = new Array(); 33 | for (var i = 0; i<_sel.length; i++){ 34 | _pos.push( 0 ); 35 | } 36 | 37 | // iterate 38 | for (i=0; i<_pos.length; i++){ 39 | // pick two random values 40 | var a = i; 41 | var b = getRandomValue(_pos); 42 | 43 | if (a != 1){ 44 | try { 45 | // flip their assets 46 | var aBox = _sel[a]; 47 | var bBox = _sel[b]; 48 | var aPos = [aBox.geometricBounds[1], aBox.geometricBounds[0]]; 49 | var bPos = [bBox.geometricBounds[1], bBox.geometricBounds[0]]; 50 | 51 | bBox.move(aPos); 52 | aBox.move(bPos); 53 | 54 | // update counter 55 | _pos[a] = 1; 56 | _pos[b] = 1; 57 | } catch(e){ 58 | 59 | } 60 | } 61 | } 62 | 63 | alert("Complete!"); 64 | } 65 | 66 | function getRandomValue(data){ 67 | var i = Math.round(Math.random()*data.length); 68 | if (data[i] == 1){ 69 | getRandomValue(data); 70 | } else { 71 | return i; 72 | } 73 | } -------------------------------------------------------------------------------- /Shuffle Page Order.jsx: -------------------------------------------------------------------------------- 1 | // Shuffle Page Order 2 | // v 2.0 3 | // 4 | // a quick script to randomly shuffle a document's pages 5 | // Bud Rodecker ©2009 / Revised J Pobojewski ©2014 6 | // 7 | 8 | var _doc = app.activeDocument; 9 | var _pages = _doc.pages; 10 | var _pageArray = []; 11 | 12 | app.doScript (main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.entireScript, "Shuffle Page Order"); 13 | 14 | function main(){ 15 | setPageArray(); 16 | 17 | for (var i=0; i< _pages.length; i++){ 18 | _pages[i].move( 19 | LocationOptions.AFTER, 20 | _pages[_pageArray[i]] 21 | ); 22 | } 23 | alert(_pages.length + " pages shuffled!"); 24 | }; 25 | 26 | function setPageArray(){ 27 | var a = []; 28 | for (var i=0; i< _pages.length; i++){ 29 | a.push(i); 30 | } 31 | _pageArray = randomizeUsingFisherYates(a); 32 | } 33 | 34 | function randomizeUsingFisherYates(myArray) { 35 | var i = myArray.length; 36 | if (i == 0) return false; 37 | while (--i) { 38 | var j = Math.floor( Math.random() * (i+1)); 39 | var tempi = myArray[i]; 40 | var tempj = myArray[j]; 41 | myArray[i] = tempj; 42 | myArray[j] = tempi; 43 | } 44 | return myArray; 45 | } --------------------------------------------------------------------------------