2 Replies Latest reply on Dec 9, 2014 9:03 PM by R-Bala-Krishnan

    Insert Page number tag

    Level 1

      Hi All

       

      For e-pub I need to inset page number tag like (<?new-page 7?>) end of every page using indesign script + xml workflow.

       

      Could you please help me.

        • 1. Re: Insert Page number tag
          Level 1

          var myf=Folder.selectDialog("Choose folder for Application File");

          if (myf != null)

          {

              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

              var myfile=myf.getFiles("*.indd");

              var a = myfile.length;

              for (var i=0; i<myfile.length;i++)

              {

                  var cur_doc=app.open(File(myfile[i],false));

                  var x = cur_doc.name;

                  var y= cur_doc.filePath+"";

                  var myname=x.replace("indd", "epub");

                  var mypath=myf+"/"+myname;

                  for (nPg=cur_doc.pages.length-1;nPg>=0;nPg--)

                  {

                     if (cur_doc.pages[nPg].textFrames.length!=0)

                     {

                      app.select(cur_doc.pages[nPg].textFrames[0].insertionPoints[0]);

                      app.selection[0].contents="<?new-page "+cur_doc.pages[nPg].name+"?>";

                      }

                  }

                  //cur_doc.exportFile(ExportFormat.epub, File(mypath))

                  //cur_doc.close(SaveOptions.NO)

              }

          }

          alert("Process Completed")

          • 2. Re: Insert Page number tag
            R-Bala-Krishnan Level 2

            For XML workflow:

             

              var target_fr = myDoc.xmlElements[0].insertionPoints[-1].parentTextFrames[0];   

              do{

                  num = target_fr.parentPage.name;

                  if (num_pre != num){

                      target_fr.insertionPoints[0].associatedXMLElements[0].xmlInstructions.add({target:'new-pa ge', data:num,  storyOffset:target_fr.insertionPoints[0]});

                      }

                  num_pre = num;

                  target_fr = target_fr.previousTextFrame;

                  }while(target_fr.parentPage.name!=myDoc.pages[0].name);

             

            Regards, Bala