4 Replies Latest reply on Feb 8, 2011 5:31 PM by John.Kordas

    Scripting Automatic Diary Dates




      I was wondering if there is a way to script an automatic date entry for the layout of diary pages in inDesign, I've attached a layout below so you can see what I mean, I dont know whether it would be better to import data from an excel sheet of to use javascript,


      I dont need the time on the left I can set these on the master, I just thought there must be  a better way than manually imputting all of the data.


      Picture 3.png


      Kind regards



        • 1. Re: Scripting Automatic Diary Dates
          [Jongware]-9BC6tI Level 4

          A fully working script, with sidesteps, is developed (by yrs trly) in this discussion:



          • 2. Re: Scripting Automatic Diary Dates
            cwrighty Level 1

            Hi Jongware,


            Thank you for that, that looks just like what i'm trying to acheive, but I'm sorrI am having difficulty with the impletmenting it. I was just wondering what is the best way of laying out the text frames to input the text. Are you best having seperate text frames and to have them flowing from one another to the next?


            Sorry I'm a real newbie to world of scripting so this is quite unfamiliar.




            • 3. Re: Scripting Automatic Diary Dates
              [Jongware]-9BC6tI Level 4

              I'd have to scan the script to know for sure, but in general I would do this:


              1. have the script generate the full list of days.

              2. determine where page breaks should come (i.e., before "Saturday" and "Wednesday")

              3. add these with a regular Find/Change -- all of the text, except for the first half week, will become overset.

              4. use Autoflow to make InDesign add the required number of pages.


              Of course this could all be added to the script, but you only have to do it once. Well, perhaps that should be "once a year".

              • 4. Re: Scripting Automatic Diary Dates
                John.Kordas Level 1

                Thanks for the code Jongware,


                I found the page layout intereseting and though I would see if I could lay out a page like the example.  The code below still needs work but its a start.


                var myDocument = app.documents.add();

                myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
                myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
                myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN; 
                    pageHeight = 297;
                    pageWidth = 210;

                var myMasterSpread = myDocument.masterSpreads.item(0);

                //Get a reference to the margin preferences of the first page in the masterspread.
                for(p=0; p<myMasterSpread.pages.length; p++){
                var myMarginPreferences = myMasterSpread.pages.item(p).marginPreferences;
                //Now set up the page margins and columns.
                myMarginPreferences.left = 5;
                myMarginPreferences.top = 5;
                myMarginPreferences.right = 5;
                myMarginPreferences.bottom = 5;
                myMarginPreferences.columnCount = 1;
                myMarginPreferences.columnGutter = 5;

                mp = app.activeDocument.masterSpreads.everyItem().pages.everyItem().getElements();

                for (i = 0; i < mp.length; i++){

                    var myLines = mp[i].textFrames.add(undefined, undefined, undefined,  {geometricBounds:[5,5,292,205]});

                    while(!(mp[i].textFrames.item(0).overflows) ){
                    mp[i].textFrames.item(0).parentStory.insertionPoints.item(-1).contents =" \r";
                    mp[i].textFrames.item(0).parentStory.paragraphs.item(0).pointSize = 12;
                    mp[i].textFrames.item(0).parentStory.paragraphs.item(0).ruleAbove = true;

                var insert = 10;for( i=0;i<7;i++){
                    myDocument.pages.item(0).textFrames.add(undefined, undefined, undefined,  {geometricBounds:[insert,180,insert+20,200],contents:"Day: "+(i+1),fillColor:"Paper"});

                    insert =insert+(297/7);