6 Replies Latest reply on Jan 29, 2012 2:09 PM by johnbullas

    Inserting filename and page numbers into multiple PDF files?

    johnbullas

      Have since seen this thread, BUT still interested in the syntax of the code

      to insert filename and page # into multiple files:

      http://forums.adobe.com/thread/951925?tstart=0

       

      Good Evening (GMT!)

       

      I have approx 100 PDFs with one or two pages in each, they are English translations

      of Russian language test certificates and the formatting/feel of the originals is lost in

      the translations. The only real link between the two sources is the "_RUS" and "_ENG"

      filename suffixes and the common leading filenames otherwise. Thus I need to maintain

      a record of the filename in any page I print off, should there be a need to refer back to

      the original if the translation is open to artistic licence.

       

      I have a script (below) that happily adds a page x/y and filename into the active file,

      what I would like is to be able to do this insertion into multiple files as defined by a

      portfolio or a selection via a select files dialogue box

       

      I am quite out of my depth now as my past skirmishes with JavaScript have set

      cookies and tweaked a few other browser doodads in webauthoring

       

      Any help most appreciated on this one...

       

      Kind Regards

       

      Dr B

      Southampton

      UK

       

      NB the filename inserted may be corrupted as a result of my last tweakings

      will sort that one out ASAP....

       

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

       

       

      // SetRemoveFooter

      // Modified as marked

      // Menu item generation

       

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

       

       

      app.addMenuItem({ cName: "Set 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)"});

      //add page x of y

       

      //

       

       

      app.addMenuItem({ cName: "Set Page ", cParent: "Footer", cExec: "SetFooter(4)"});

       

      app.addMenuItem({ cName: "Set Both", cParent: "Footer", cExec: "SetFooter(5)"});

      //

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

      //

      app.addMenuItem({ cName: "Remove Both", cParent: "Footer", cExec: "RemoveFooter(5)"});

       

      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 = "dd/mm/yyyy"

       

      var Box2Width = 100

       

      for (var p = 0; p < this.numPages; p++)

       

      {

       

      var aRect = this.getPageBox("Crop",p);

       

      var TotWidth = aRect[2] - aRect[0]

       

      if (ARG<=3 || ARG==5)

       

      {var fd = this.addField("xftDate", "text", p, [30,15, TotWidth-30-30,30]);

       

      //print output?

       

      fd.value = util.printd(AcDateFormat, AcDate) + " (" + FileNM +")";

      // TEXT SIZE SETTING

      fd.textSize=12; 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)

       

      {var bStart=(TotWidth/2)-(Box2Width/2)

       

      var bEnd=((TotWidth/2)+(Box2Width/2))

       

      var fp = this.addField(String("xftPage"+p+1), "text", p, [bStart,30,bEnd,15]);

      // print output?

       

      fp.value = "Page: " + String(p+1)+ "/" + this.numPages;

      // TEXT SIZE SETTING

      fp.textSize=12; fp.readonly = true;

       

      fp.alignment="center";

       

      }

       

      } }

       

      //

      //==========================================================================

      //

      function RemoveFooter(ARG)

       

      {

       

      if (ARG<=3 || ARG==5) {var x = this.removeField("xftDate");}

       

      if (ARG==2 || ARG==5) {for (var p = 0; p < this.numPages; p++)

       

      {

       

      var x = this.removeField(String("xftPage"+p+1)); }

       

      } },

      will