0

The Situation:

My Script creates a weekplanner with the masterpage as template.

What's happening in the script is:

  • Create Page
  • Apply Masterpage
  • Override each item
  • Change content of each item
  • do this for the whole dates-array length

The Problem:

The position of the masterPageItems after overriding gets messed up. I've made two screenshots as demonstration.

Now the real weirdness about this is, that it gets messed up on a "custom-size" document, but it doesn't get messed up on A4-Format...

I've already tried to restore the geometricBounds of each item after overriding it, but this doesnt seem to work either...

Do you have any idea what could be causing this behaviour?

The masterpage: https://i.stack.imgur.com/u0PAh.png

Messed up after overriding: https://i.stack.imgur.com/0AWvh.png


EDIT: As proof that restoring the geometricBounds doesn't work, I did the following:

function OverrideMasterItems(currPage) {  
  var allItems = currPage.masterPageItems;  
  var itemPos;
  for(var i=0;i<allItems.length;i++){  
    try{
        itemPos = allItems[i].geometricBounds;
        allItems[i].override(currPage);
        allItems[i].geometricBounds = itemPos;
        $.writeln("Original itemPos: " + itemPos);
        $.writeln("New itemPos: " + allItems[i].geometricBounds);
        if(itemPos == allItems[i].geometricBounds) {
            $.writeln("same position");
        }
    }  
    catch(e){}  
  }  
} 

As you see I assign the items original geometric bounds again and in the console it says that it's the same value - but it looks like in the screenshots. Also it doesn't write "same position" - which means the if-statement isn't true...

der-lukas
  • 936
  • 9
  • 13

1 Answers1

0

I solved it! For future reference:

It wasn't a programming bug, but some awkward InDesign "Bug(?!)" that lead to this weird behaviour:

I copied the elements of the Masterpage from a different document, that had different dimensions, and I just resized the textfields to fit the new format.

That's what caused the behaviour - it seems like the textfields still have some information from the other document I got it from and that this information wasn't removable/editable.

Because even deleting the paragraph styles etc. didn't change the weird behaviour...

As I'm pretty new to InDesign scripting I don't know if this a common thing you guys know about, but this gave me headaches... ;)

EDIT 1: I didn't solve it! Still not working sometimes!

Okay, it's still happening, and I just don't understand why... As the script executes the "override" on an item, the item gets repositioned to a completely wrong position...

der-lukas
  • 936
  • 9
  • 13