Edit an Indesign script for me?

Hi all!

I'm fairly new to Indesign scripting and I have a script here that I would have changed.

This script puts a several page pdf in an Indesign file and add pages as needed. From now this script appears in a dialog box that asks you what document I want than the PDF to be placed in, and I would like to have this dialog box eleminated and have the script automatically place the pdf file in the document I have active. This script also asked which page to start to put the pdf file on and I would if it would simply just start automatically on the first page of the Indesign document active without even asking me. Someone would be willing to make these changes for the script below and zip code on this thread? Let me know if I did something clear.

var myDocument = app.activeDocument;
//Get the current page.
main();
function main(){
  //Display a standard Open File dialog box.
  var myPDFFile = File.openDialog("Choose a PDF File");
  if((myPDFFile != "")&&(myPDFFile != null)){
  var myDocument, myPage;
  if(app.documents.length != 0){
  var myTemp = myChooseDocument();
  myDocument = myTemp[0];
  myNewDocument = myTemp[1];
  }
  else{
  myDocument = app.documents.add();
  myNewDocument = false;
  }
  if(myNewDocument == false){
  myPage = myChoosePage(myDocument);
  }
  else{
  myPage = myDocument.pages.item(0);
  }
  myPlacePDF(myDocument, myPage, myPDFFile);
  }
}
function myChooseDocument(){
    var myDocumentNames = new Array;
    myDocumentNames.push("New Document");
    //Get the names of the documents
    for(var myDocumentCounter = 0;myDocumentCounter < app.documents.length; myDocumentCounter++){
        myDocumentNames.push(app.documents.item(myDocumentCounter).name);
    }
    var myChooseDocumentDialog = app.dialogs.add({name:"Choose a Document", canCancel:false});
    with(myChooseDocumentDialog.dialogColumns.add()){
        with(dialogRows.add()){
            with(dialogColumns.add()){
                staticTexts.add({staticLabel:"Place PDF in:"});
            }
            with(dialogColumns.add()){
                var myChooseDocumentDropdown = dropdowns.add({stringList:myDocumentNames, selectedIndex:0});
            }
        }
    }
  var myResult = myChooseDocumentDialog.show();
  if(myResult == true){
  if(myChooseDocumentDropdown.selectedIndex == 0){
  myDocument = app.documents.add();
  myNewDocument = true;
  }
  else{
  myDocument = app.documents.item(myChooseDocumentDropdown.selectedIndex-1);
  myNewDocument = false;
  }
  myChooseDocumentDialog.destroy();
  }
  else{
  myDocument = "";
  myNewDocument = "";
  myChooseDocumentDialog.destroy();
  }
    return [myDocument, myNewDocument];
}
function myChoosePage(myDocument){
    var myPageNames = new Array;
    //Get the names of the pages in the document
    for(var myCounter = 0; myCounter < myDocument.pages.length;myCounter++){
        myPageNames.push(myDocument.pages.item(myCounter).name);
    }
    var myChoosePageDialog = app.dialogs.add({name:"Choose a Page", canCancel:false});
    with(myChoosePageDialog.dialogColumns.add()){
        with(dialogRows.add()){
            with(dialogColumns.add()){
                staticTexts.add({staticLabel:"Place PDF on:"});
            }
            with(dialogColumns.add()){
                var myChoosePageDropdown = dropdowns.add({stringList:myPageNames, selectedIndex:0});
            }
        }
    }
    myChoosePageDialog.show();
    var myPage = myDocument.pages.item(myChoosePageDropdown.selectedIndex);
    myChoosePageDialog.destroy();
    return myPage;
}
function myPlacePDF(myDocument, myPage, myPDFFile){
  var myPDFPage;
  app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
  var myCounter = 1;
  var myBreak = false;
  while(myBreak == false){
  if(myCounter > 1){
  myPage = myDocument.pages.add(LocationOptions.after, myPage);
  }
  app.pdfPlacePreferences.pageNumber = myCounter;

     myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
  if(myCounter == 1){
  var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
  }
  else{
  if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){
  myPage.remove();
  myBreak = true;
  }
  }
  myCounter = myCounter + 1;
  }
}
var myPDFFrame =  myPlacePDF.parent;

Thank you very much in advance for your help! I greatly appreciate it!

This is a rewrite for you. I also added some code to remove empty pages in the document.

/*

PlaceMulitpagePDF condensed by Skemicle Script

*/

If (parseFloat (app.version)<>

main();

on the other

app.doScript (principal, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Place Multipage PDF");

main() {} function

var myPDFFile is File.openDialog ("choose a PDF file");.

If ((myPDFFile! = "") & (myPDFFile!) (= null)) {}

var = app.activeDocument myDocument,

myPage = myDocument.pages.item (0);

var myPDFPage;

app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;

var myCounter = 1;

var myBreak = false;

while(myBreak == false) {}

If (myCounter > 1) {}

my page = myDocument.pages.add (LocationOptions.after, myPage);

}

app.pdfPlacePreferences.pageNumber = myCounter;

myPDFPage = myPage.place (File (myPDFFile), [0,0]) [0];

if(MyCounter == 1) {}

New var features = myPDFPage.pdfAttributes.pageNumber;

} else {}

if(myPDFPage.pdfAttributes.PageNumber == myFirstPage) {}

myPage.remove ();

myBreak = true;

}

} myCounter = myCounter + 1;

}

} var pages = app.activeDocument.pages;

for (c = 0; c<>

If (pages.pageItems.length [c] == 0) {}

pages [c]. Remove();

}

}

}

Tags: InDesign

Similar Questions

  • PDF-to-InDesign script for the folio

    Hello

    I downloaded the script above to create a folio of pdf in ID6. I would use it to publish on devices Android, but understand that a Horizontal scrolling in the DPS should be turned off to enable the pinch to zoom on Android devices feature. However, when we use this script, it creates an article in ID 2 page (with the exception of the front and back covers), that is, when Horizontal scrolling is disabled, scrolling occurs on the Android device which makes it very confusing to navigate the magazine.

    My questions are, we can modify the script so that it produces unique page ID files and if so will pinch to zoom work with specific items?

    Thank you

    Charlotte

    Hello

    I adopted the script for several scenarios, which may be useful. It can certainly be more managed.

    Claudio, to answer your question, Yes, you can adjust the offset value in the script. I did it for our PDFs with versions below.

    I made changes in the script which include the following:

    1. Drop the required naming convention. Page names should be ordered now 1 - x. Ex: 1.pdf "Page, 'Page 2', 'Page 35.pdf', etc. I added a sort function to sort problems where there is a # different numbers in the numerical value of page. Note that the word "Page" is not necessary.
    2. This allows spaces in file names.
    3. Note that the script still requires the sidecar to the command files correctly. Folio Builder will import an article "Page 10" before "Page 2"when you perform an import multiple article.»

    Here is one who creates 1024 x 600 H & V. page layouts (target: Kindle Fire 7 "SD.) Note, due to a limitation of Android/DPS of the flattened chimneys not being is no PtZ, you can not PtZ.)

    Here is one who creates layouts of 1280 x 800 H & V. (target: Kindle Fire 7 '' HD Note, due to a limitation of Android/DPS of the flattened chimneys being don't not PtZ, you can't PtZ.)

    Here is one that creates only provisions of 1280 x 800 h. (target: light the fire 7 '' HD.) Given that this includes no flat batteries, you can use PtZ).

    Here is one who creates layouts of 1920 x 1200 H & V. (target: Kindle Fire 8.9 "HD Note, due to a limitation of Android/DPS of the flattened chimneys not being don't not PtZ, you can't PtZ.)

    We were just testing some of these options, in that no guarantees are these infallible. However, if you encounter a problem, feel free to shoot me a PM and I'll see if I can fix it for you.

    Concerning the PtZ is not not available for items flattened in the Android, my discussions Adobe viewers has no desire to fix this / add features to their current viewers focus on the air. When they release a viewer Android native (Q1?) it would probably be a valid request if it is not available from the start.

    See you soon

  • InDesign script for a text of color replace all other lines in a text box

    I have a very long list of names I need to alternate the color CMYK, all other rows value.

    I found this script on another thread to adobe changing the hue of every 3rd line:

    var i, p; for (i=0; i<app.selection[0].paragraphs.length; i++) { p = app.selection[0].lines[i]; if (i%3 === 2) { p.fillTint = 50; } } 

    I tried to change the script to change the value of CMYK, do this:

    var i, p; for (i=0; i<app.selection[0].paragraphs.length; i++) { p = app.selection[0].lines[i]; if (i%2 === 1) { p.colorValue=[0,100,100,0]; } } 

    But using 'colorValue' is not supported. How can I change the script to do all the other lines in a text box to change the value of the color?

    var i, p, color;
    for (i=0; i		   
  • XHTML for digital editions on Indesign Server

    Hi all

    I have a problem exporting to ePub on an Indesign server.

    I tried to look in the "XHTML for digital editions" - files in indesign CS4 and CS5 facilities, but it is seems protected jsxbin. It looks like a 'black box' - delivery.

    My next step was the "Indesign server sdk" that has a fine example, called "DigitalEditionsSample.jsx".

    That works well in the indesign product, but I had no luck with the server version.

    It keeps telling me that there is a problem with "layoutwindows". I know that "layoutwindows" are not available in the version of the server. But the "layoutwindows" are called somewhere in the OEBExporter and it's still a jsxbin.

    Is there a solution to my problem?

    Where can I get just the scripts instead of the jsxbin?

    Thanks for your reply,

    Glen

    If you download the full SDK for CS4/CS5, you can get them (and many more (much, much more)).

    Attention however: on a scale of Javascript experience of 1 to 10, it would measure about 8 - it is quite advanced. But on a scale of InDesign scripting, they turn off the chart - the writer used all possible stuff available in the DOM of InDesign to speed things up.

  • Fast Java Script for indesign issue.

    Normal java code will work in indesign?  For example, if I find a good bit of code I want to integrate into indesign scripts?

    Yes, with the following exceptions:

    1 no browser-specific code. (no document, window, etc.)

    2. no modern Javascript features will not work. ExtendScript uses an older version of SpiderMonkey under the hood. Stick to ECMAScript 4.

    It is worth noting that ExtendScript supports E4X, XML is a first class citizen.

  • Scripts for indesign

    Hi all.  I wonder if there is a script for indesign that allow me to put the file name / and identifiers of color at the bottom of the Document.  Also, who will all place me information where I want.  For ex...   I want to send a task to plates and rather than manually enter the name of the file - Date and time - and colors on the bottom of the plate/file.  I know that when I go to export a file or print a file it is check box to put the information on the file page and it does what I want however he put the information too low on the plate.  He added the information down into the corner of the plate area and receiving not Burnt or processed in this area.  I need a script to back up the information, if we read.

    Hi cbishop01,

    First of all, I would not recommend research by sending your files to Indesign as postscript, if your normal process is a PDF workflow. PostScript does not support some features on various output devices. When the postscript from Indesign, you can run into CMYK printing issues when dealing with PDF files and other works of art that contain some transparency effects and mixing modes that cannot be interpreted by the postscript or cannot flatten properly.

    My employer uses a script Indesign, we have developed which can be something similar to what you are looking to accomplish. If your plate is always the same size, you can create a model of tax file in Indesign with job info, color chart, date and time, and you want to integrate the model tax. You can use a script Indesign to automatically update the model every time that you print in PDF format (which can be done by adding a custom ease menu item).

    Plate files vary from a file in a file, you can convert the file name, time, blocks of color name text in an Indesign library item and drop it right in the position desired on each individual plate installation. You will not have to change these items, you will only place a group element where you want to go.

    Is this something that will work for you?

    (example of a model of plate file)

    (example of slug color library item)

  • Need help to create a Script for the labelling of Finder of Indesign files

    Try to find a way to have a script run in InDesign CS4, who tagged a RED text file once it's been imported into InDesign.

    Import multiple text files in an InDesign template. Since there are several text files in the same folder, it must somehow 'delineate' that we have imported this file and move to the next import. I created a 'service' with a keyboard shortcut Automator to label the Red file in the finder, but it would be great if we could have this occurs automatically after we imported in InDesign.

    If import us the text wrong by accident and it gets missed in fermentation, it costs us a lot of money with the printer.

    Thanks for all the ideas.

    Jim

    At its heart, it's what you want to do.

    tell application "Adobe InDesign CS4"
         set placeFile to choose file
         tell active document
              tell selection
                   --Assumes you have preselected the picture or textbox to place file in
                   place placeFile
              end tell
         end tell
    end tell
    tell application "Finder"
         set label index of placeFile to 2
    end tell
    

    You can expand on it pretty easily. The script for InDesign dictionary must be in the Library palette in the Applescript editor and the docs for Applescript are all online.

    If you need further assistance, you may wish to ask someone to write a complete script for you to spec for real moneyz.

    Best o ' luck!

    Eric.

  • use Image catalog script for the current document

    Is it possible to use the script to image catalogue for the current document in which we work instead of leaving the mark of script a new document fees for placed images?

    use,

    //ImageCatalog.jsx
    //An InDesign CS6 JavaScript
    /*
    @@@BUILDINFO@@@ "ImageCatalog.jsx" 3.0.0 15 December 2009
    */
    //Creates an image catalog from the graphic files in a selected folder.
    //Each file can be labeled with the file name, and the labels are placed on
    //a separate layer and formatted using a paragraph style ("label") you can
    //modify to change the appearance of the labels.
    //
    //For more information on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html
    //Or visit the InDesign Scripting User to User forum at http://www.adobeforums.com .
    //
    //The myExtensions array contains the extensions of the graphic file types you want
    //to include in the catalog. You can remove extensions from or add extensions to this list.
    //myExtensions is a global. Mac OS users should also look at the file types in the myFileFilter function.
    main();
    function main(){
      var myFilteredFiles;
      //Make certain that user interaction (display of dialogs, etc.) is turned on.
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
      myExtensions = [".jpg", ".jpeg", ".eps", ".ps", ".pdf", ".tif", ".tiff", ".gif", ".psd", ".ai"]
      //Display the folder browser.
      var myFolder = Folder.selectDialog("Select the folder containing the images", "");
      //Get the path to the folder containing the files you want to place.
      if(myFolder != null){
      if(File.fs == "Macintosh"){
      myFilteredFiles = myMacOSFileFilter(myFolder);
      }
      else{
      myFilteredFiles = myWinOSFileFilter(myFolder);
      }
      if(myFilteredFiles.length != 0){
      myDisplayDialog(myFilteredFiles, myFolder);
      alert("Done!");
      }
      }
    }
    //Windows version of the file filter.
    function myWinOSFileFilter(myFolder){
      var myFiles = new Array;
      var myFilteredFiles = new Array;
      for(myExtensionCounter = 0; myExtensionCounter < myExtensions.length; myExtensionCounter++){
      myExtension = myExtensions[myExtensionCounter];
            myFiles = myFolder.getFiles("*"+ myExtension);
      if(myFiles.length != 0){
      for(var myFileCounter = 0; myFileCounter < myFiles.length; myFileCounter++){
      myFilteredFiles.push(myFiles[myFileCounter]);
      }
      }
      }
      return myFilteredFiles;
    }
    function myMacOSFileFilter(myFolder){
      var myFilteredFiles = myFolder.getFiles(myFileFilter);
      return myFilteredFiles;
    }
    //Mac OS version of file filter
    //Have to provide a separate version because not all Mac OS users use file extensions
    //and/or file extensions are sometimes hidden by the Finder.
    function myFileFilter(myFile){
      var myFileType = myFile.type;
      switch (myFileType){
      case "JPEG":
      case "EPSF":
      case "PICT":
      case "TIFF":
      case "8BPS":
      case "GIFf":
      case "PDF ":
      return true;
      break;
      default:
      for(var myCounter = 0; myCounter-1){
      return true;
      break;
      }
      }
      }
      return false;
    }
    function myDisplayDialog(myFiles, myFolder){
      var myLabelWidth = 112;
      var myStyleNames = myGetParagraphStyleNames(app);
      var myLayerNames = ["Layer 1", "Labels"];
      var myDialog = app.dialogs.add({name:"Image Catalog"});
      with(myDialog.dialogColumns.add()){
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Information:"});
      }
      with(borderPanels.add()){
      with(dialogColumns.add()){
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Source Folder:", minWidth:myLabelWidth});
      staticTexts.add({staticLabel:myFolder.path + "/" + myFolder.name});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Number of Images:", minWidth:myLabelWidth});
      staticTexts.add({staticLabel:myFiles.length + ""});
      }
      }
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Options:"});
      }
      with(borderPanels.add()){
      with(dialogColumns.add()){
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Number of Rows:", minWidth:myLabelWidth});
      var myNumberOfRowsField = integerEditboxes.add({editValue:3});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Number of Columns:", minWidth:myLabelWidth});
      var myNumberOfColumnsField = integerEditboxes.add({editValue:3});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Horizontal Offset:", minWidth:myLabelWidth});
      var myHorizontalOffsetField = measurementEditboxes.add({editValue:12, editUnits:MeasurementUnits.points});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Vertical Offset:", minWidth:myLabelWidth});
      var myVerticalOffsetField = measurementEditboxes.add({editValue:24, editUnits:MeasurementUnits.points});
      }
      with (dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Fitting:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myFitProportionalCheckbox = checkboxControls.add({staticLabel:"Proportional", checkedState:true});
      var myFitCenterContentCheckbox = checkboxControls.add({staticLabel:"Center Content", checkedState:true});
      var myFitFrameToContentCheckbox = checkboxControls.add({staticLabel:"Frame to Content", checkedState:true});
      }
      }
      with(dialogRows.add()){
      var myRemoveEmptyFramesCheckbox = checkboxControls.add({staticLabel:"Remove Empty Frames:", checkedState:true});
      }
      }
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:""});
      }
      var myLabelsGroup = enablingGroups.add({staticLabel:"Labels", checkedState:true});
      with (myLabelsGroup){
      with(dialogColumns.add()){
      //Label type
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Type:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelTypeDropdown = dropdowns.add({stringList:["File name", "File path", "XMP description", "XMP author"], selectedIndex:0});
      }
      }
      //Text frame height
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Height:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelHeightField = measurementEditboxes.add({editValue:24, editUnits:MeasurementUnits.points});
      }
      }
      //Text frame offset
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Offset:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelOffsetField = measurementEditboxes.add({editValue:0, editUnits:MeasurementUnits.points});
      }
      }
      //Style to apply
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Style:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:0});
      }
      }
      //Layer
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Layer:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLayerDropdown = dropdowns.add({stringList:myLayerNames, selectedIndex:0});
      }
      }
      }
      }
            var myResult = myDialog.show();
            if(myResult == true){
      var myNumberOfRows = myNumberOfRowsField.editValue;
      var myNumberOfColumns = myNumberOfColumnsField.editValue;
      var myRemoveEmptyFrames = myRemoveEmptyFramesCheckbox.checkedState;
      var myFitProportional = myFitProportionalCheckbox.checkedState;
      var myFitCenterContent = myFitCenterContentCheckbox.checkedState;
      var myFitFrameToContent = myFitFrameToContentCheckbox.checkedState;
      var myHorizontalOffset = myHorizontalOffsetField.editValue;
      var myVerticalOffset = myVerticalOffsetField.editValue;
      var myMakeLabels = myLabelsGroup.checkedState;
      var myLabelType = myLabelTypeDropdown.selectedIndex;
      var myLabelHeight = myLabelHeightField.editValue;
      var myLabelOffset = myLabelOffsetField.editValue;
      var myLabelStyle = myStyleNames[myLabelStyleDropdown.selectedIndex];
      var myLayerName = myLayerNames[myLayerDropdown.selectedIndex];
      myDialog.destroy();
      myMakeImageCatalog(myFiles, myNumberOfRows, myNumberOfColumns, myRemoveEmptyFrames, myFitProportional, myFitCenterContent, myFitFrameToContent, myHorizontalOffset, myVerticalOffset, myMakeLabels, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle,  myLayerName);
            }
      else{
      myDialog.destroy();
      }
      }
    }
    function myGetParagraphStyleNames(myDocument){
      var myStyleNames = new Array;
      var myAddLabelStyle = true;
      for(var myCounter = 0; myCounter < myDocument.paragraphStyles.length; myCounter++){
      myStyleNames.push(myDocument.paragraphStyles.item(myCounter).name);
      if (myDocument.paragraphStyles.item(myCounter).name == "Labels"){
      myAddLabelStyle = false;
      }
      }
      if(myAddLabelStyle == true){
      myStyleNames.push("Labels");
      }
      return myStyleNames;
    }
    function myMakeImageCatalog(myFiles, myNumberOfRows, myNumberOfColumns, myRemoveEmptyFrames, myFitProportional, myFitCenterContent, myFitFrameToContent, myHorizontalOffset, myVerticalOffset, myMakeLabels, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle,  myLayerName){
      var myPage, myFile, myCounter, myX1, myY1, myX2, myY2, myRectangle, myLabelStyle, myLabelLayer;
      var myParagraphStyle, myError;
      var myFramesPerPage = myNumberOfRows * myNumberOfColumns;
      var myDocument = app.activeDocument;
      myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
      myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
      var myDocumentPreferences = myDocument.documentPreferences;
      var myNumberOfFrames = myFiles.length;
      var myNumberOfPages = Math.round(myNumberOfFrames / myFramesPerPage);
      if ((myNumberOfPages * myFramesPerPage) < myNumberOfFrames){
      myNumberOfPages++;
      }
      //If myMakeLabels is true, then add the label style and layer if they do not already exist.
      if(myMakeLabels == true){
      try{
      myLabelLayer = myDocument.layers.item(myLayerName);
      //if the layer does not exist, trying to get the layer name will cause an error.
      myLabelLayer.name;
      }
      catch (myError){
      myLabelLayer = myDocument.layers.add({name:myLayerName});
      }
      //If the paragraph style does not exist, create it.
      try{
      myParagraphStyle = myDocument.paragraphStyles.item(myLabelStyle);
      myParagraphStyle.name;
      }
      catch(myError){
      myDocument.paragraphStyles.add({name:myLabelStyle});
      }
      }
      myDocumentPreferences.pagesPerDocument = myNumberOfPages;
      myDocumentPreferences.facingPages = false;
      var myPage = myDocument.pages.item(0);
      var myMarginPreferences = myPage.marginPreferences;
      var myLeftMargin = myMarginPreferences.left;
      var myTopMargin = myMarginPreferences.top;
      var myRightMargin = myMarginPreferences.right;
      var myBottomMargin = myMarginPreferences.bottom;
      var myLiveWidth = (myDocumentPreferences.pageWidth - (myLeftMargin + myRightMargin)) + myHorizontalOffset
      var myLiveHeight = myDocumentPreferences.pageHeight - (myTopMargin + myBottomMargin)
      var myColumnWidth = myLiveWidth / myNumberOfColumns
      var myFrameWidth = myColumnWidth - myHorizontalOffset
      var myRowHeight = (myLiveHeight / myNumberOfRows)
      var myFrameHeight = myRowHeight - myVerticalOffset
      var myPages = myDocument.pages;
      // Construct the frames in reverse order. Don't laugh--this will
      // save us time later (when we place the graphics).
      for (myCounter = myDocument.pages.length-1; myCounter >= 0; myCounter--){
      myPage = myPages.item(myCounter);
      for (var myRowCounter = myNumberOfRows; myRowCounter >= 1; myRowCounter--){
      myY1 = myTopMargin + (myRowHeight * (myRowCounter-1));
      myY2 = myY1 + myFrameHeight;
      for (var myColumnCounter = myNumberOfColumns; myColumnCounter >= 1; myColumnCounter--){
      myX1 = myLeftMargin + (myColumnWidth * (myColumnCounter-1));
      myX2 = myX1 + myFrameWidth;
      myRectangle = myPage.rectangles.add(myDocument.layers.item(-1), undefined, undefined, {geometricBounds:[myY1, myX1, myY2, myX2], strokeWeight:0, strokeColor:myDocument.swatches.item("None")});
      }
      }
      }
      // Because we constructed the frames in reverse order, rectangle 1
      // is the first rectangle on page 1, so we can simply iterate through
      // the rectangles, placing a file in each one in turn. myFiles = myFolder.Files;
      for (myCounter = 0; myCounter < myNumberOfFrames; myCounter++){
      myFile = myFiles[myCounter];
      myRectangle = myDocument.rectangles.item(myCounter);
      myRectangle.place(File(myFile));
      myRectangle.label = myFile.fsName.toString();
      //Apply fitting options as specified.
      if(myFitProportional){
      myRectangle.fit(FitOptions.proportionally);
      }
      if(myFitCenterContent){
      myRectangle.fit(FitOptions.centerContent);
      }
      if(myFitFrameToContent){
      myRectangle.fit(FitOptions.frameToContent);
      }
      //Add the label, if necessary.
      if(myMakeLabels == true){
      myAddLabel(myRectangle, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle, myLayerName);
      }
      }
      if (myRemoveEmptyFrames == 1){
      for (var myCounter = myDocument.rectangles.length-1; myCounter >= 0;myCounter--){
      if (myDocument.rectangles.item(myCounter).contentType == ContentType.unassigned){
      myDocument.rectangles.item(myCounter).remove();
      }
      else{
      //As soon as you encounter a rectangle with content, exit the loop.
      break;
      }
      }
      }
    }
    //Function that adds the label.
    function myAddLabel(myFrame, myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName, myLayerName){
      var myDocument = app.documents.item(0);
      var myLabel;
      var myLabelStyle = myDocument.paragraphStyles.item(myLabelStyleName);
      var myLabelLayer = myDocument.layers.item(myLayerName);
      var myLink =myFrame.graphics.item(0).itemLink;
      //Label type defines the text that goes in the label.
      switch(myLabelType){
      //File name
      case 0:
      myLabel = myLink.name;
      break;
      //File path
      case 1:
      myLabel = myLink.filePath;
      break;
      //XMP description
      case 2:
      try{
      myLabel = myLink.linkXmp.description;
      if(myLabel.replace(/^\s*$/gi, "")==""){
      throw myError;
      }
      }
      catch(myError){
      myLabel = "No description available.";
      }
      break;
      //XMP author
      case 3:
      try{
      myLabel = myLink.linkXmp.author
      if(myLabel.replace(/^\s*$/gi, "")==""){
      throw myError;
      }
      }
      catch(myError){
      myLabel = "No author available.";
      }
      break;
      }
      var myX1 = myFrame.geometricBounds[1];
      var myY1 = myFrame.geometricBounds[2] + myLabelOffset;
      var myX2 = myFrame.geometricBounds[3];
      var myY2 = myY1 + myLabelHeight;
      var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel});
      myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;
      myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;
    }
    
  • Script for application of hyperlinks to text

    Hello

    I made a people directory document in InDesign using the data merge. Each person has information on access to its URL to social networks (LinkedIn, Twitter).

    Is it possible to do a script that search the InDesign document for all channels that looks like this:

    LinkedIn profile: http://a-very-long-URL

    and transforms them in all the LinkedIn profile , but with the URL applied as a hyperlink?

    If it's easier to search/replace operation I could mark the string without delimiters before executing the script, to avoid complex URL detection scripts. Maybe something like this (Markdown style): [LinkedIn profile] (http://a-very-long-url/)

    Thank you!

    Hello

    Quick snippet, try...

    var doc = app.activeDocument;
    // get URL
    app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat = '(?i)(?<=LinkedIn Profile: )(https?|www)\\S+\\>';
    var mURL  = doc.findGrep();
    // get Texte
    app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat = 'LinkedIn Profile:';
    var mSource  = doc.findGrep();
    
    for (var k = 0; k 		   
  • How to pass the content of an xml element in the text frame in inDesign Script

    var XMLFile = File.openDialog ("select XML Files... ») ;

    var doc = app.activeDocument;

    If (!) App.Documents.Length)

    {alert ("ERROR: Document not opened");}

    return;

    }

    doc.importXML (XMLFile);

    var firstFigureNode = doc.xmlElements [0] .xmlElements [1] .xmlElements [0];

    var lableNode = firstFigureNode.xmlElements [0];

    var lableNodeText = lableNode.contents;

    myFrame var = doc.textFrames.add ({geometricBounds: [-13, 13, 3, -3]});

    lableNodeText.move (LocationOptions.AFTER, myFrame.texts [0]);

    ========================================================

    My requirement is: == > > move the content of an xml element in the text by inDesign Script block, but XML InDesign file Structure should not be change & data in the XML Structure should remain as it was before...

    I tried to code above, but it does not work...

    Please can someone help me in solving this problem...

    It does not work correctly...

    It moves firstFigureNode in myFrame...

    firstFigureNode.placeXML (myFrame);

    ===>> For Apple Script try below Code ===>>

    myFrame markup using firstFigureNode

  • Script for the mandatory boxes

    Recently I've been editing a PDF file with checkboxes for the steps in a process. Basically, these just will be used when going through the process to check off each step individual as long as the user goes along. There was a high requirement to prevent the checkboxes of the audit until the previous one has been checked. So box 2 cannot be controlled until the box 1 have been verified, and 3 cannot be controlled until 2 is checked etc.

    Does anyone could offer some advice on a script for this? My knowledge of scripting languages is quite limited, so any help would be greatly appreciated! Thank you.

    Thanks for all the help.

    I finally managed to find a piece of code that shows the next box hidden but also hide the check box, so that from before is not checked. Here's the code I used just in case anyone is interested.

    var nHide = event.target.isBoxChecked (0)? display.visable:display.hidden;

    this.getField("Check_Box2").display = nHide;

    Once again thanks for the help.

    -James

  • I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    Hello

    Can the code below is useful for you, but I do not know how to sort.

    Change the tag based on your employment application.

  • InDesign script to run on the action?

    Hi, can someone help - is it possible to set up an indesign script to be triggered to perform an action, for example when you export to PDF (instead of manually running the script)? To explain, I have a script that creates a text box to display the size of the indesign document, but if the size of the page change the text box does not update unless you manually run the script again. so I was wondering if it was possible to put the script to run when the document is exported to PDF, so in theory be PDFd with the size of the pages always display up-to-date!

    I approach this issue perspective, as altogether new to the am scripts.

    Thanks in advance for any suggestions.

    Hi Trevor - thank you very much for this - (after a bit of trial and error with changes!) managed to make it work.

    Work of great stuff.

    Thanks again

  • Running scripts for hours in saved state?

    I hope you don't mind a little dreamy logic...

    is it possible to simulate the operation of a script for hours, without really leaving the virtual machine on for hours.

    In my case, I have some code which according to Core Java Volume 1 (8th edition), should run in a stalemate, however, because of the intermittent nature of the bug, we can't predict under what circumstances, the deadlock will cause the machine to stop.

    Therefore, it would be ideal to have scripts run in the virtual machine (development environment) and somehow automatically have the dump script results, screenshots, and save the State of the environment at the same time the bug occurs.  The source code that run in the JDK 1.6 are attached and are compressed in rar . format

    Additional information can be found by reading Core Java Volume 1 (8th edition http://www.amazon.com/Core-Java-I-Fundamentals-8th-Horstmann/dp/0132354764) and Oracle tutorial on blocks to http://download.oracle.com/javase/tutorial/essential/concurrency/deadlock.html.

    Without the virtual machine must be running in order to run the script-

  • Script for automatic placement of several text files?

    An editor I work with is slowed by a change to their workflow. Maybe there's a whole script for help? I looked but can not find, so I post here.

    Old workflow: Designers would be "automatic formatting" a single Word doc with all the preliminary pages (sometimes > 10 sections of diff.) and chapters and endnotes in a model book.

    New workflow: The Word doc is now divided into 30-40 InCopy files, always destined to a single InDesign layout doc (The InCopy files were created from a Word doc marked by a different system, so that they are all new to the InDesign user.)

    Y at - it a script which, according designers load a square slider with 30-40 (in the right order) files, which will allow them to simple-click on page 1, and InDesign will place one after the other files, autoflowing necessary? They still need them to be placed in individual InCopy files (so would not help concatenate Prime). I don't think that there is never a case of 2 stories being on the same page.

    Thank you

    AM

    Hey AnneMarie,

    This script allows you to select a bunch of files and will try to place them, one by one, in your InDesign document. It will be auto-flux them according to the needs (but be careful because standing in excess of problems - because the script does not test for this).

    I tested with a lot of property, but not with InCopy files because I did not. If they are adjustable as Word documents, the script must run end.

    Let us know if everything works correctly for you.

    // BS"D
    // Multi-file auto-place
    // An InDesign Script by Ariel, (c) Id-Extras.com, 2014
    // This script will allow the user to select a bunch of placeable files (Word docs, etc.)
    // It will then attempt to place and auto-flow all the selected files.
    // The script will start from page 1 of the active document
    // and keep adding pages as needed.
    // It will add text frames as needed, within the margins of the page.
    // IMPORTANT: There is no error-checking for perpetual overflow!!!
    // So, if something you're trying to place cannot fit within the margins,
    // The script will continue adding pages to InDesign until it crashes.
    // To quit the script, press ESC.
    var myDoc = app.activeDocument,
     myFiles = File.openDialog("Select files to place...", undefined, true),
     i,
     currentPage = myDoc.pages[0],
     prevFrame,
     myFrame;
    
    for (i = 0; i < myFiles.length; i++){
     myFrame = addFrame(currentPage);
     myFile = myFiles[i];
     try{
      myFrame.place(myFile, false);
     }
     catch(e){
      alert("Unable to place file: "+myFile, "Multi-file auto-place");
      continue;
     }
     while (myFrame.overflows){
      currentPage = addPageAfter(currentPage);
      prevFrame = myFrame;
      myFrame = addFrame(currentPage);
      prevFrame.nextTextFrame = myFrame;
     }
     currentPage = addPageAfter(currentPage);
    }
    function addFrame(aPage){
     var pageMargins = aPage.marginPreferences,
      aFrame = aPage.textFrames.add(),
      areFacing = app.activeDocument.documentPreferences.facingPages,
      myTop = aPage.bounds[0]+pageMargins.top,
      myBottom = aPage.bounds[2]-pageMargins.bottom,
      myLeft = aPage.bounds[1]+pageMargins.left,
      myRight = aPage.bounds[3]-pageMargins.right;
     //When document.documentPreferences.facingPages == true,
     //"left" means inside; "right" means outside.
     if (areFacing && aPage.side == PageSideOptions.LEFT_HAND){
       myLeft = aPage.bounds[1]+pageMargins.right;
       myRight = aPage.bounds[3]-pageMargins.left;
     }
     aFrame.geometricBounds = [myTop, myLeft, myBottom, myRight];
     return aFrame;
    }
    
    function addPageAfter(aPage){
     return myDoc.pages.add(LocationOptions.AFTER, aPage);
    }
    

Maybe you are looking for