does anyone have a .jsx script to "fit frame to content" for text and graphic boxes on all pages?
fit frame to content
Pass variable from JSX to VBS
Hello,
With ExtendScript I'm attempting to pass arguments to a VBS script from inside of a JSX script. I see that the arguments can be passed but I'm not sure how to retrieve those from inside of the VBS shell.
This is the example from AppleScript on OSX to read some text from a file using the cat command.
// establish array
ARG = [];
// establish variable
pathARG = "/path/to/file";
// push variable into array
ARG.push( pathARG );
// create AppleScript
var readTextScript = 'set filePath to item 1 of arguments\r'
readTextScript += 'do shell script "cat " & filePath';
// execute script with arguments
myResult = app.doScript( readTextScript, ScriptLanguage.APPLESCRIPT_LANGUAGE, ARG );
And here's an attempt to do the same with VBS script using the ReadAll command which fails.
// create VBS script
var readTextScript = 'Set wshShell = CreateObject( "WScript.Shell" )\r' +
'Set filePath = wshShell.Arguments.Item(0)\r' +
'Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(filePath,1)\r' +
'strFileText = objFileToRead.ReadAll()\r' +
'objFileToRead.Close\r' +
'returnValue = strFileText';
var myResult = app.doScript( readTextScript,ScriptLanguage.VISUAL_BASIC, ARG );
Error message: "Object doesn't support this property of method: 'wshShell.Arguments'
Any help would be appreciated!
--
Jared Annear
Can I cancel checkOut
Good morning,
I'm working with some files with InCopy links. Right now, I check out the links, do some stuff and check them back in. Then close without saving.
The problem is that the next time I open the document, all the links need to be updated.
You can cancel a checkout in indd, but I'm not seeing a method for it in js https://www.indesignjs.de/extendscriptAPI/indesign11/#Story.html#d1e475084__d1e480497
Am I missing it, or does it not exist?
Converting all hyperlinks to footnotes or endnotes
Hi everyone, I figured there would already be a script out there that would accomplish this, but can anyone point me in the right direction on converting all hyperlinks in a document into either footnotes or endnotes? For example, for a digital version of a book, there is lots of hyperlinked text items throughout. If this book were to be converted into a print version, the hyperlinked text's hyperlinks would not be available and you'd have to individually extract out each hyperlink, insert a footnote/endnote and then paste the hyperlink into the footnote/endnote area. This is very tedious. A script seems like the obvious solution. Any ideas? Thanks!
Diff b/w inline and anchored object and script to find them
hi ..
I see in the forum there are inline objects and anchored object, can someone explain what's the difference between them?
Are they the same?
if not, is there a way to create script to find an anchored but not inline object?
Thank you so much..
Resize PageItem Loop
Hi, I'm trying to resize pageItems by looping through and adjusting the width of pageItems (which is in mm). I think that resizing must be in points, but that'll be easy for me to figure out later.
I know it'd be faster to use the collection of pageItems but as I'm sure you can tell I'm a beginner & am trying to get as much as possible out of the exercise.
Im using CS6 & the object model appears to be 7.5 (in ExtendScript). Originally when I was selecting the pageItems this would be shown as I stepped through the code, but now I can't seem to get that to work since using the variable myCounter as the subscript. No doubt I'm doing something wrong there also.
Could anyone advise what I'm doing wrong here. Spent a lot of time searching but there's so many different versions of JS in Adobe it seems. Also I don't trust the Object Model Viewer as it says PageItem; which always fails when I step-through, only pageItem works when I step through so it's a battle with my proverbial arm tied behind my back from the start.
Pass variable from JSX to VBS
Hello,
With ExtendScript I'm attempting to pass arguments to a VBS script from inside of a JSX script. I see that the arguments can be passed but I'm not sure how to retrieve those from inside of the VBS shell.
This is the example from AppleScript on OSX to read some text from a file using the cat command.
// establish array
ARG = [];
// establish variable
pathARG = "/path/to/file";
// push variable into array
ARG.push( pathARG );
// create AppleScript
var readTextScript = 'set filePath to item 1 of arguments\r'
readTextScript += 'do shell script "cat " & filePath';
// execute script with arguments
myResult = app.doScript( readTextScript, ScriptLanguage.APPLESCRIPT_LANGUAGE, ARG );
And here's an attempt to do the same with VBS script using the ReadAll command which fails.
// create VBS script
var readTextScript = 'Set wshShell = CreateObject( "WScript.Shell" )\r' +
'Set filePath = wshShell.Arguments.Item(0)\r' +
'Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(filePath,1)\r' +
'strFileText = objFileToRead.ReadAll()\r' +
'objFileToRead.Close\r' +
'returnValue = strFileText';
var myResult = app.doScript( readTextScript,ScriptLanguage.VISUAL_BASIC, ARG );
Error message: "Object doesn't support this property of method: 'wshShell.Arguments'
Any help would be appreciated!
--
Jared Annear
'Object Invalid' when trying to remove() a pageItem
Hi,
I'm successfully getting a reference to a non-threaded text frame that I want to delete, but calling .remove() on it results in error 45 'Object is invalid'
Seems like this code should work? But it doesn't :-(
// alert(workbooklegal) // InDesign alert: [Object PageItem]
workbooklegal.remove();
Converting all hyperlinks to footnotes or endnotes
Hi everyone, I figured there would already be a script out there that would accomplish this, but can anyone point me in the right direction on converting all hyperlinks in a document into either footnotes or endnotes? For example, for a digital version of a book, there is lots of hyperlinked text items throughout. If this book were to be converted into a print version, the hyperlinked text's hyperlinks would not be available and you'd have to individually extract out each hyperlink, insert a footnote/endnote and then paste the hyperlink into the footnote/endnote area. This is very tedious. A script seems like the obvious solution. Any ideas? Thanks!
[ID-CS5][JS] Pasting into a rectangle at same position
Hi,
I am trying to make a script and have been successful to a point...
I have content on a layer labeled "copy-layer"
Also, rectangles and polygons marking areas of copy-layer on another layer called "export-layer"
I want to copy all of the content from copy-layer inot each individual shape from export-layer
This will help me export selection(i.e. individual shape) to JPEG.
I struggling to pasteinto() theses shapes and locate copied content at same position as it was on copy-layer.
Any help will be appreciated.
Thank You
johnD
Layout Adjustment property ---- InDesign CC Server
I am experiencing problem when we are trying to enable the Layout Adjustment property through InDesign CC Server_Scripting.
app.documents[0].layoutAdjustmentPreferences.enableLayoutAdjustment=true;
Could you please if anybody helps us to solve this problem?
Create swatch from Pantone name
I thought it was possible for a script to create a new swatch from a Pantone name. For example, given the name 'PANTONE 7696 C' I can (manually) create a new swatch in the Swatches panel, in the Colour Mode dropdown select 'PANTONE+ Solid Coated', then enter '7696' in the entry field. When I click OK the swatch is added to the panel.
How do I do this with a script?
Thanks,
P.
Batch update Paragraph Styles across multiple tempates
Is there such a script, extension or plugin?
Text Frame event listener
Hi,
I want to create a listener for a text frame, to evaluate the value when it changes (from a data merge) and use it to show/hide layers in the document. Possible? I can't quite put my finger on it.
Convert more than two line breaks (soft and/or hard) into two
Hello, I am developing a script (using extended script) in InDesign and it basically imports several docx files, some of these documents come with many line breaks (soft and hard, mixed).
What I need to do is remove excess line breaks (when it's more than two) for just two breaks. What action is best to take?
Below is an example of what I am talking about:
This came from 3 different files.
Delete comments from active page
Hi, is there any way to delete (or mark as resolved) all pdf comments from the current page using a script? Thanks.
Position of an library asset on the page – how to get it?
First of all, I would like to thank very much all the participants in the previous thread that I started a few days ago. I wasn't sure where to write the answer with thanks, so unfortunately I didn't write anything.... It was not nice. I'm sorry. Your solutions and discussions were very impressive and helpful. Thank you again !
Today I'm asking for help in understanding:
– where Indesign?/document?/library?/asset? keeps the information about position values of the library asset on page which is used by placeAsset() method?
– how to get the values or setnew values to placeAsset()
– is it possible to set position ( or maybe annother properties ) of placed library asset by script?
Than you for any suggestion or solution
a.
Smart casing for Title Case with Script
Hi,
I have working on a very large document which requires conversion of a particular paragraph style to Title case with smart casing such that words like A, An, The and so on and so forth, cover sentence case style, and other words follow Title Casing. In order to follow the approach I came across a brilliant script (bg thank you to @Dave Saunders) which converts the heading with smart casing:
Changing Sentence Case in a Paragraph Style? - Adobe Indesign Windows
//DESCRIPTION Converts selected text to title case smartly //Smartly means that articles, etc. are ignored //and internal capitals of recognized words are retained. ignoreWords = ["a","and","the","to","with","in","on","as","of","o r","at","is","from","for"]; intCaps = ["PineRidge","InDesign","NJ","UMC"]; try { myText = app.selection[0].texts[0].contents; } catch(e) { exit(); } theWords = myText.toLowerCase().split(" "); //First word must have a cap, but might have an internal cap myNewText = ""; for (var j = 0; theWords.length > j; j++) { k = isIn(intCaps,theWords[j]) if (k > -1) { myNewText = myNewText + intCaps[k] + " "; continue; } else { if ((isIn(ignoreWords,theWords[j]) > -1) && (j != 0)) { myNewText = myNewText + theWords[j] + " "; } else { myNewText = myNewText + InitCap(theWords[j]) + " "; } } } app.selection[0].texts[0].contents = myNewText.substring(0,myNewText.length - 1); function isIn(aList,aWord) { for (var i = 0; aList.length > i; i++) { if (aList[i].toLowerCase() == aWord) { return i; } } return -1; } function InitCap(aWord) { if (aWord.length == 1) { return (aWord.toUpperCase()); } return (aWord.substr(0,1).toUpperCase() + aWord.substring(1,aWord.length)) }
The issue is that I have around 100+ headings for which I have to do this. In order to find a quicker approach, I found another script by Dave Saunders updated by Zalmanf which changes casing of a particular paragraph style at once without smart casing:
Updating Dave Saunders find style/change case script
//DESCRIPTION: Update of Dave Saunder's ChangeCaseOfSelectedStyle script to replace either Paragraph and Character Styles if ((app.documents.length != 0) && (app.selection.length != 0)) { myDoc = app.activeDocument; myCStyles = myDoc.characterStyles; myCStringList = myCStyles.everyItem().name; myPStyles = myDoc.paragraphStyles; myPStringList = myPStyles.everyItem().name; myCaseList = ["Uppercase","Lowercase", "Title case", "Sentence case"]; myCases = [ChangecaseMode.uppercase, ChangecaseMode.lowercase, ChangecaseMode.titlecase, ChangecaseMode.sentencecase]; var myDialog = app.dialogs.add({name:"Case Changer"}) with(myDialog){ with(dialogColumns.add()){ with (dialogRows.add()) { with (dialogColumns.add()) { staticTexts.add({staticLabel:"Character Style:"}); } with (dialogColumns.add()) { myCStyle = dropdowns.add({stringList:myCStringList,selectedIndex:0,minWidth:133}); } } with (dialogRows.add()) { with (dialogColumns.add()) { staticTexts.add({staticLabel:"Paragraph Style:"}); } with (dialogColumns.add()) { myPStyle = dropdowns.add({stringList:myPStringList,selectedIndex:0,minWidth:133}); } } with (dialogRows.add()) { with (dialogColumns.add()) { staticTexts.add({staticLabel:"Change Case to:"}); } with (dialogColumns.add()) { myCase = dropdowns.add({stringList:myCaseList,selectedIndex:0,minWidth:133}); } } } } var myResult = myDialog.show(); if (myResult != true){ // user clicked Cancel myDialog.destroy(); errorExit(); } theCStyle = myCStyle.selectedIndex; thePStyle = myPStyle.selectedIndex; theCase = myCase.selectedIndex; myDialog.destroy(); app.findTextPreferences = NothingEnum.NOTHING; app.changeTextPreferences = NothingEnum.NOTHING; if (theCStyle > 0) { app.findTextPreferences.appliedCharacterStyle = myCStyles [theCStyle]; } if (thePStyle > 0) { app.findTextPreferences.appliedParagraphStyle = myPStyles [thePStyle]; } var myFinds = myDoc.findText(); myLim = myFinds.length; for (var j=0; myLim > j; j++) { myFinds[j].texts[0].changecase(myCases[theCase]); } } else { errorExit(); } // +++++++ Functions Start Here +++++++++++++++++++++++ function errorExit(message) { if (arguments.length > 0) { if (app.version != 3) { beep() } alert(message); } exit(); }
Both these scripts are amazing and really help in improving the efficiency of the work flow, however, in order to apply smart casing I have to first run the second script to change casing of all headings and then apply first script for smart casing output.
Is it possible to amalgamate both scripts in such a way that we are able to change the case of any of the style at once with smart Title casing.
Any kind of guidance would be greatly appreciated. Also, Thank you Dave Saunders for sharing your vase pool of knowledge with the world. Big thank you!
Regards,
Aman Mittal
Pass variable from JSX to VBS
Hello,
With ExtendScript I'm attempting to pass arguments to a VBS script from inside of a JSX script. I see that the arguments can be passed but I'm not sure how to retrieve those from inside of the VBS shell.
This is the example from AppleScript on OSX to read some text from a file using the cat command.
// establish array
ARG = [];
// establish variable
pathARG = "/path/to/file";
// push variable into array
ARG.push( pathARG );
// create AppleScript
var readTextScript = 'set filePath to item 1 of arguments\r'
readTextScript += 'do shell script "cat " & filePath';
// execute script with arguments
myResult = app.doScript( readTextScript, ScriptLanguage.APPLESCRIPT_LANGUAGE, ARG );
And here's an attempt to do the same with VBS script using the ReadAll command which fails.
// create VBS script
var readTextScript = 'Set wshShell = CreateObject( "WScript.Shell" )\r' +
'Set filePath = wshShell.Arguments.Item(0)\r' +
'Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(filePath,1)\r' +
'strFileText = objFileToRead.ReadAll()\r' +
'objFileToRead.Close\r' +
'returnValue = strFileText';
var myResult = app.doScript( readTextScript,ScriptLanguage.VISUAL_BASIC, ARG );
Error message: "Object doesn't support this property of method: 'wshShell.Arguments'
Any help would be appreciated!
--
Jared Annear
Create swatch from Pantone name
I thought it was possible for a script to create a new swatch from a Pantone name. For example, given the name 'PANTONE 7696 C' I can (manually) create a new swatch in the Swatches panel, in the Colour Mode dropdown select 'PANTONE+ Solid Coated', then enter '7696' in the entry field. When I click OK the swatch is added to the panel.
How do I do this with a script?
Thanks,
P.