6 Replies Latest reply on May 15, 2013 3:54 AM by Learner Learner

    Need to avaid placing floats one after one on the same place

    Learner Learner Level 1

      Hi All,

       

      I have written a script for placing floats after the citation it works only for either the figure or table. But if both figure and table citation comes on the same place the script placing the floats one on one.

       

      How to control this?

       

      Thanks in advance,

      Learner

        • 1. Re: Need to avaid placing floats one after one on the same place
          Jump_Over Level 5

          Hi,

           

          pretty complex question...

          1. you place them as anchored or as standalone boxes?

          2. how you detect correct "after the citation" place?

           

          Jarek

          • 2. Re: Need to avaid placing floats one after one on the same place
            Learner Learner Level 1

            Hi Jarek,

             

            1. standalone boxes

            2. Getting the pagenumber of the citation and the baseline position of the citation

                 if (pagehight-bottommargin) - baseline of the citation > hight of the image)

                 then im placing the image under the citation on the bottom of the same page

                 else

                 im placing the image onto the top of the next page

             

            thanks

            Learner

            • 3. Re: Need to avaid placing floats one after one on the same place
              Sajeev Sridharan Level 4

              Hi,

               

              Please clarify the below points:

               

              is it a XML workflow or non-xml workflow?

              How you are capturing tables and figures in to a standalone boxes?

               

              Vandy

              • 4. Re: Need to avaid placing floats one after one on the same place
                Learner Learner Level 1

                Hi Vandy,

                 

                It is a xml workflow.

                 

                Here is the script.

                 

                function caption(){

                    this.name = "caption";

                    this.xpath = "//caption";

                          this.apply = function(caption,){

                        with(caption){

                            var mydoc = app.activeDocument;

                            var pwidth = mydoc.documentPreferences.pageWidth;

                            var pheight = mydoc.documentPreferences.pageHeight;

                            var topmargin = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.top;    

                            var bottommargin = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.bottom;

                            var insidemarginfirstmaserpage = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.left;

                            var outsidemarginfirstmaserpage = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.right;

                            var y1 = topmargin;

                            var x1 = outsidemarginfirstmaserpage;

                            var y2 = pheight - bottommargin;

                            var x2 = pwidth- insidemarginfirstmaserpage;           

                            citpage = figCitationPage.name;

                            textfm = placeIntoFrame(app.activeDocument.pages.item(citpage), [y1, x1, y2, x2]);

                            textfm.fit(FitOptions.FRAME_TO_CONTENT);

                            textfm.appliedObjectStyle = mydoc.objectStyles.item("oSlug");

                            mydoc.xmlImportMaps.add(mydoc.xmlTags.item("caption"), mydoc.paragraphStyles.item("Slug"));

                            mydoc.mapXMLTagsToStyles();

                            textfm.textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

                            textfm.textFramePreferences.ignoreWrap = true;

                            var textfmy1 = textfm.geometricBounds[0];

                            var textfmx1 = textfm.geometricBounds[1];

                            var textfmy2 = textfm.geometricBounds[2];

                            var textfmx2 = textfm.geometricBounds[3];

                            figfmy1 = figfm.geometricBounds[0];

                            figfmx1 = figfm.geometricBounds[1];

                            figfmy2 = figfm.geometricBounds[2];

                            figfmx2 = figfm.geometricBounds[3];

                            textfm.geometricBounds = [textfmy1,textfmx1,textfmy2,x2];

                            textfm.move([textfmy1, figfmy2]);

                            textfm.fit(FitOptions.FRAME_TO_CONTENT);

                            var myPage = mydoc.pages.everyItem();

                            var myArray = new Array;

                            myArray.push(figfm);

                            myArray.push(textfm);

                            var t = (textfmy2-textfmy1)

                            var groupitem = figCitationPage.groups.add(myArray);

                            var citbaseline = exbm - citpos;

                            var test = parseInt(citpage)

                            var citbaseline = exbm - citpos;

                            var test = parseInt(citpage)

                            if (citbaseline<groupitem.geometricBounds[2]){

                                    groupitem.move(app.activeDocument.pages[test]);

                                    groupitem.move([x1,y1])

                                }

                            else {

                                    var by1 = groupitem.geometricBounds[0];

                                    var by2 = groupitem.geometricBounds[2];

                                    var t = (by2-by1)

                                    groupitem.move([x1, (y2-t)])

                                }

                        }

                        return true;

                    }

                }

                 

                 

                function figure(){

                    this.name = "figure";

                    this.xpath = "//figure";

                          this.apply = function(figure,){

                        with(figure){

                            var mydoc = app.activeDocument;

                            var pwidth = mydoc.documentPreferences.pageWidth;

                            var pheight = mydoc.documentPreferences.pageHeight;

                            var topmargin = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.top;    

                            var bottommargin = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.bottom;

                            var insidemarginfirstmaserpage = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.left;

                            var outsidemarginfirstmaserpage = app.activeDocument.masterSpreads.item(0).pages.item(0).marginPreferences.right;

                            //var insidemarginsecondmaserpage = app.activeDocument.masterSpreads.item(0).pages.item(1).marginPreferences.left;

                            //var outsidemarginsecondmaserpage = app.activeDocument.masterSpreads.item(0).pages.item(1).marginPreferences.right;

                            var y1 = topmargin;

                            var x1 = outsidemarginfirstmaserpage;

                            //var x1recto = AMinsidemargin

                            var y2 = pheight - bottommargin;

                            var x2 = pwidth- insidemarginfirstmaserpage;           

                            //var x2recto = pwidth- AMoutsidemargin;

                            citpage = figCitationPage.name;

                            figfm = placeIntoFrame(app.activeDocument.pages.item(citpage), [y1, x1, y2, x2]);

                            figfm.fit(FitOptions.FRAME_TO_CONTENT);

                            figfm.textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;

                            figfm.textFramePreferences.ignoreWrap = true;

                            figfm.appliedObjectStyle = mydoc.objectStyles.item("ofigure");

                            fy1 = figfm.geometricBounds[0];

                            fx1 = figfm.geometricBounds[1];

                            fy2 = figfm.geometricBounds[2];

                            fx2 = figfm.geometricBounds[3];

                        }

                        return true;

                    }

                }

                • 5. Re: Need to avaid placing floats one after one on the same place
                  Sajeev Sridharan Level 4

                  one final question, can you tell me the xml structure of figures, tables and citation tags used in the indesign document.

                   

                  Vandy

                  • 6. Re: Need to avaid placing floats one after one on the same place
                    Learner Learner Level 1

                    Hi Vandy,

                     

                    Figure : component/body/section/figure

                    Figure caption : component/body/section/figure/caption

                     

                    Citation : component/body/section/p/link