13 Replies Latest reply on Jan 19, 2012 3:16 PM by try67

    HOW CAN I BATCH ADD ONLY THE FILENAME TO PDF?

    ZILIDIAN

      I saw a long thread about adding javascript code to insert date, time and filename. but it is an old thread that i cannot comment on.

       

      So please help me only add the filename to the footer

       

      This is the code that was poseted by Rindhard(sp?) This code adds all three.. I only want to have the filename but everytime I try to rem out a line it doesnt work.. i do not know java script obviously

       

      I want to add the filename in a calibri 12pt font

       

      thanks for any help!

       

      app.addSubMenu({ cName: "Footer",cUser: "Set/Remove Footer", cParent: "File", nPos: 20 });

      app.addMenuItem({ cName: "Set Date Time (Filename)", cParent: "Footer", cExec: "SetFooter(1)"});
      app.addMenuItem({ cName: " ->  Set Date .... centered", cParent: "Footer", cExec: "SetFooter(2)"});
      app.addMenuItem({ cName: " ->  Set Date .... right", cParent: "Footer", cExec: "SetFooter(3)"});
      app.addMenuItem({ cName: "Set Page centered", cParent: "Footer", cExec: "SetFooter(4)"});
      app.addMenuItem({ cName: " -> Set Page right", cParent: "Footer", cExec: "SetFooter(5)"});
      app.addMenuItem({ cName: "Set Both", cParent: "Footer", cExec: "SetFooter(9)"});

      app.addMenuItem({ cName: "-------------------------------", cParent: "Footer",cExec: "{}"});

      app.addMenuItem({ cName: "Remove Both", cParent: "Footer", cExec: "RemoveFooter(9)"});
      app.addMenuItem({ cName: "Remove Date Time (Filename)", cParent: "Footer", cExec: "RemoveFooter(1)"});
      app.addMenuItem({ cName: "Remove Page", cParent: "Footer", cExec: "RemoveFooter(4)"});


      //Set/remove Footer
      function SetFooter(ARG)
      {
      var re = /.*\/|\.pdf$/ig;
      var FileNM = this.path.replace(re,"")+".pdf";
      var Path = this.path;
      var AcDate = new Date();
      var AcDateFormat = "yyyy/mmm/dd  HH:MM"
      var Box2Width = 50
      for (var p = 0; p < this.numPages; p++)
      {
        var aRect = this.getPageBox("Crop",p);
        var TotWidth = aRect[2] - aRect[0]
        if (ARG<=3 || ARG==9)
         { var fd = this.addField("xftDate", "text", p, [30,15, TotWidth-30-30,30]);
            fd.value =  util.printd(AcDateFormat, AcDate) + "   (" + FileNM +")";
             fd.textSize=6; fd.readonly = true;
             if (ARG==1){ fd.alignment="left" };
             if (ARG==2){ fd.alignment="center" };
             if (ARG==3){ fd.alignment="right" };
          }
        if (ARG==4 || ARG==5 ||ARG==9)
         {  var bStart=(TotWidth/2)-(Box2Width/2)
             var bEnd=((TotWidth/2)+(Box2Width/2))
             if (ARG==5){var bStart=(TotWidth-Box2Width-30); var bEnd=(TotWidth-30);}
             var fp = this.addField(String("xftPage"+p+1), "text", p, [bStart,30,bEnd,15]);
             fp.value = "Page: " + String(p+1)+ "/" + this.numPages;
             fp.textSize=6;  fp.readonly = true;
             fp.alignment="center";
         }
      }
      }

      function RemoveFooter(ARG)
      {
      if (ARG<=3 || ARG==9) {var x = this.removeField("xftDate");}
      if (ARG==4 || ARG==9)
         {  for (var p = 0; p < this.numPages; p++)
            {var x = this.removeField(String("xftPage"+p+1)); }
         }
      }