7 Replies Latest reply on Jan 4, 2017 10:33 PM by keyank99503373

    Slug script

    talltim1 Level 1

      Is there a script that can add the slug area, a text frame, and variable to any document, though. It could be run on single files or entire folders?


      The only variable I require is the documents filename.


      I have a very large amount of indesign docs I need PDF'd, but I need the file name on the PDF as they will be printed. And sometimes they will be printed straight from indesign. I have more and more indesign documents arriving from many sources every day too, so a scripted solution is probably better for me than trying to get people to supply them with correct slug set-up.


      Thanks in advance, Tim

        • 1. Re: Slug script
          [Jongware] Most Valuable Participant

          In principal this is not really hard -- the good news. But I'd like to know a few more details.


          How much slug would you need? Should it only be at the bottom, or all around? Where do you want the file name to appear -- on the first page only, on one or all master pages, or on every single page, or spread?


          Would you like your slug text in Black, or in Registration color?


          If working on a folder, would you want it to open, change, then close & save documents in the same place?

          • 2. Re: Slug script
            talltim1 Level 1



            Slug would be width of the document, whatever size that is at 10pt.

            On the top only.

            One every single page or spread.

            In black.

            Open, change, close and save in same place is fine.


            Thanks for your help. Tim.

            • 3. Re: Slug script
              [Jongware] Most Valuable Participant

              Seems no problem. I'm at work right now, but hopefully to-nite I can find half an hour or so to look into it.

              • 4. Re: Slug script
                talltim1 Level 1

                Cheers, much appreciated.

                • 5. Re: Slug script
                  [Jongware] Most Valuable Participant

                  It's hot & stuffy here at home (above 30° -- Celsius) but I think I got the first half right. This script will add slug and a text variable to the current document, put it into a frame, and copy it around to the top left of all pages.

                  I have to freshen up on how to run it on multiple documents (one of the other scripters might have a good framework for that--didn't something pass by just last week? (Too hot .. can't think ..)).


                  //DESCRIPTION:Add File name to slug
                  // Jongware, 20-Jul-2010
                  doc = app.activeDocument;
                  // Add File name variable
                  try {
                       fname = doc.textVariables.add({name:"SlugFilename", variableType:VariableTypes.FILE_NAME_TYPE});
                       // Change where necessary:
                       with (fname.variableOptions)
                            includeExtension = false;
                            includePath = false;
                            textBefore = "File: ";
                            textAfter = "";
                  } catch (_)
                       fname = doc.textVariables.item("SlugFilename");
                  // Set slug at top
                  orgRuler = doc.viewPreferences.rulerOrigin;
                  doc.viewPreferences.rulerOrigin = RulerOrigin.SPINE_ORIGIN;
                  doc.documentPreferences.slugTopOffset = "10mm";
                  // Add a frame to first page
                  frame = doc.pages[0].textFrames.add({geometricBounds:["-9mm","2mm","-5mm","50mm"]});
                  frame.insertionPoints[-1].properties = {appliedFont:"Arial", fontStyle:"Bold", pointSize:8, fillColor:doc.swatches.item("Black") };
                  frame.texts[0].textVariableInstances.add().associatedTextVariable = fname;
                  // Duplicate to all pages on correct position
                  for (p=0; p<doc.pages.length; p++)
                       f = frame.duplicate (doc.pages[p]);
                       if (doc.pages[p].side == PageSideOptions.LEFT_HAND)
                            f.move ([-doc.documentPreferences.pageWidth, "-9mm"]);
                       else if (doc.pages[p].side == PageSideOptions.RIGHT_HAND)
                            f.move ([0, "-9mm"]);
                  // Original may not be at correct position, so delete
                  doc.viewPreferences.rulerOrigin = orgRuler;
                  1 person found this helpful
                  • 6. Re: Slug script
                    talltim1 Level 1

                    Thanks so far. I'm in Ireland, so we don't get to complain about the heat too much here!

                    • 7. Re: Slug script
                      keyank99503373 Level 1

                      If i need to insert bottom of the page. what i have to change in the below line.


                      frame = doc.pages[0].textFrames.add({geometricBounds:["-9mm","2mm","-5mm","50mm"]});