2 Replies Latest reply on Nov 9, 2015 2:14 AM by LeoMari

    Insert auto credit for images.

    LeoMari Level 2

      It can enter text frame next to the picture frame?

      I intend to make a text box to enter credit to images.

      The text box can be empty or to say "Enter the credit."

      Screen Shot 2015-11-05 at 11.53.18 AM.png

      I tried using captions but I can not position it as shown.

      Thanks for helping!

        • 1. Re: Insert auto credit for images.
          Kasyan Servetsky Level 5

          Here's a "quick and dirty" script. Totally untested. Change the space, width and height variables (with comments) to whatever values you need in millimeters, or change the measurement units to those you use.

          var scriptName = "Insert auto credit for images",
          doc;
          
          PreCheck();
          
          function Main() {
              var horUnits = doc.viewPreferences.horizontalMeasurementUnits,
              verUnits = doc.viewPreferences.verticalMeasurementUnits,
              sel = app.selection[0],
              gb = sel.geometricBounds,
              top = gb[0],
              right = gb[3],
              space = 1, // space between the image and the credit frame
              width = 5, // the width of the credit frame
              height = 30; // the height of the credit frame
          
              if (sel.parentPage.constructor.name == "Page") {
                  var page = sel.parentPage;
                  var creditFrame = page.textFrames.add();
                  creditFrame.rotationAngle = 90;
                  creditFrame.geometricBounds = [top, right + space, top + height, right + space + width];
                  creditFrame.contents = "Enter the credit.";
                  
              }
              
              doc.viewPreferences.horizontalMeasurementUnits = horUnits;
              doc.viewPreferences.verticalMeasurementUnits = verUnits;
          }
          
          function PreCheck() {
              if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
              doc = app.activeDocument;
              if (doc.converted) ErrorExit("The current document has been modified by being converted from older version of InDesign. Please save the document and try again.", true);
              if (!doc.saved) ErrorExit("The current document has not been saved since it was created. Please save the document and try again.", true);
              if (doc.selection.length == 0) ErrorExit("Nothing is selected. Please select an image and try again.", true);
              if (doc.selection.length > 1) ErrorExit("Please select only one image and try again.", true);
              Main();
          }
          
          function ErrorExit(error, icon) {
              alert(error, scriptName, icon);
              exit();
          }