Override elements by script problems

I need to override elements by script and have them end up at the same place they were in master. Now it overrides and puts them to the new page but it changes their position. Here is my function:

function loadPagesAndOverrideElements(document, csvData) {

    // add pages defined in CSV and correct layout

    for (var i=0; csvData.numberOfRows>i; i++) {

        var masterSpread = document.masterSpreads.itemByName(csvData["master"]);

        document.pages.add();

        document.pages[i+1].appliedMaster = masterSpread;

        var allItems = document.pages[i+1].appliedMaster.pageItems.everyItem().getElements();

        for(var j=0;j<allItems.length;j++){

            try {

                allItems.override(document.pages[i+1]);

            } catch(e) {

                // alert(e);

            }

        }

    }

    document.pages[0].remove();

    return document;

}

Uwe, Trevor, tomas8,

Thanks to Uwe's investigations/tests I finally came up with a scripted solution that sounds clean to me—but it still needs to be tested in CS5/5.5.

My main finding is that the matrix Page.masterPageTransform (property available in CS5 and later) accurately reflects the shift we are trying to circumvent.

When a new page is created in the 'corrupted' document based on any master spread, CS6 and CC show the following result:

alert( myNewPage.masterPageTransform.matrixValues );

// => 1,0,0,1,-150,-150      Here it is!

As far as I understand this matrix determines the transformation "applied to the master page before it is applied to Page," that is, how the page is mapped to its master page. In normal case that should be—I suppose—the IDENTITY matrix.

My guess is that CS6/CC improperly uses those matrix values during scripted overrides, so that we have to explicitly apply the inverse matrix to the newly created page, as follows:

var document = app.activeDocument; 

var csvData = {

    "master" : ["A-Master", "B-Master", "C-Master"],

    "numberOfRows" : 3

    };

 

loadPagesAndOverrideElements(document, csvData);

 

 

function loadPagesAndOverrideElements(document, csvData)

{

    // Constants

    // ---

    const CS_INNER = +CoordinateSpaces.innerCoordinates,

          ORIGIN = [[0,0],CS_INNER];

   

    // Variables

    // ---

    var i, n = csvData.numberOfRows,

        ms, pg, mx;

    // Unlock ALL layers

    // ---

    document.layers.everyItem().locked = false;

    // Page creation loop

    // ---

    for( i=0 ; i < n ; ++i )

        {

        // Select the master spread

        // ---

        ms = document.masterSpreads.itemByName(csvData["master"]);

       

        // Create new page and override master items

        // ---

        ms.pageItems.everyItem().override( pg=document.pages.add({appliedMaster:ms}) );

        // Revert the masterPageTransform if needed

        // ---

        (mx=pg.properties.masterPageTransform) && pg.transform(CS_INNER, ORIGIN, mx.invertMatrix());

        }

   

    // Remove the 1st page

    // ---

    document.pages[0].remove();

};

Seems to work for me.

What about CS5?

@+

Marc

Topics

Scripting

Views

9.9K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More

Override elements by script problems

I need to override elements by script and have them end up at the same place they were in master. Now it overrides and puts them to the new page but it changes their position. Here is my function:

function loadPagesAndOverrideElements(document, csvData) {

    // add pages defined in CSV and correct layout

    for (var i=0; csvData.numberOfRows>i; i++) {

        var masterSpread = document.masterSpreads.itemByName(csvData["master"]);

        document.pages.add();

        document.pages[i+1].appliedMaster = masterSpread;

        var allItems = document.pages[i+1].appliedMaster.pageItems.everyItem().getElements();

        for(var j=0;j<allItems.length;j++){

            try {

                allItems.override(document.pages[i+1]);

            } catch(e) {

                // alert(e);

            }

        }

    }

    document.pages[0].remove();

    return document;

}

Uwe, Trevor, tomas8,

Thanks to Uwe's investigations/tests I finally came up with a scripted solution that sounds clean to me—but it still needs to be tested in CS5/5.5.

My main finding is that the matrix Page.masterPageTransform (property available in CS5 and later) accurately reflects the shift we are trying to circumvent.

When a new page is created in the 'corrupted' document based on any master spread, CS6 and CC show the following result:

alert( myNewPage.masterPageTransform.matrixValues );

// => 1,0,0,1,-150,-150      Here it is!

As far as I understand this matrix determines the transformation "applied to the master page before it is applied to Page," that is, how the page is mapped to its master page. In normal case that should be—I suppose—the IDENTITY matrix.

My guess is that CS6/CC improperly uses those matrix values during scripted overrides, so that we have to explicitly apply the inverse matrix to the newly created page, as follows:

var document = app.activeDocument; 

var csvData = {

    "master" : ["A-Master", "B-Master", "C-Master"],

    "numberOfRows" : 3

    };

 

loadPagesAndOverrideElements(document, csvData);

 

 

function loadPagesAndOverrideElements(document, csvData)

{

    // Constants

    // ---

    const CS_INNER = +CoordinateSpaces.innerCoordinates,

          ORIGIN = [[0,0],CS_INNER];

   

    // Variables

    // ---

    var i, n = csvData.numberOfRows,

        ms, pg, mx;

    // Unlock ALL layers

    // ---

    document.layers.everyItem().locked = false;

    // Page creation loop

    // ---

    for( i=0 ; i < n ; ++i )

        {

        // Select the master spread

        // ---

        ms = document.masterSpreads.itemByName(csvData["master"]);

       

        // Create new page and override master items

        // ---

        ms.pageItems.everyItem().override( pg=document.pages.add({appliedMaster:ms}) );

        // Revert the masterPageTransform if needed

        // ---

        (mx=pg.properties.masterPageTransform) && pg.transform(CS_INNER, ORIGIN, mx.invertMatrix());

        }

   

    // Remove the 1st page

    // ---

    document.pages[0].remove();

};

Seems to work for me.

What about CS5?

@+

Marc

Topics

Scripting

Views

9.9K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More

Re: Override elements by script problems

I've moved your question tot he scripting forum, but you should understand that once overridden, the object will be part of the regular stacking order for that layer, and in front of any other master page objects that are not overridden.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

The layer order is not a problem, problem is the element position. When I use override from indesign menu element stayes in its position, but when I use script it moves to some random position.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

I'm not a scripter, so I can't help with writing the script, but what you describe sounds like a bug in ID, not your script. Do you have the latest update for your version of ID installed?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Yes I do, I am using creative cloud and latest version of ID. Its hard to say if it's a bug or there is some another way in scripting for overriding. Is there any scripter to help?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

This is where the scripters hang out. Have a little patience.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Are you really sure, that your items move to a random value? I would assume, that the items do not move, instead the problem occurs, when you delete a page and your left pages get applied a right master page and so on!

Otherwise please provide a .idml-file, a runnable snippet of your script (incl. the csv-part).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

I would send you the files you need but I don't have your mail. I did not find any option to upload file in here.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

You see the mail of a user, if you are logged in and hover over the name of the user.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Kai Rübsamen wrote:

You see the mail of a user, if you are logged in and hover over the name of the user.

That's true for ordinary users ONLY if the other user has made their email public. You can however, send a link to a file on Dropbox or another share service by clciking a user's name and sending a private message or email through the forum systems. You can also post a link publicly here.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Is your master spread a single page or multiple pages?

If it's multiple pages, you need to make sure that the object is on the same master page location as the local page. If it's simple facing pages, you can compare the side property...

Harbs

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , Apr 24, 2014

@tomas8 – Can you post some screen shots to give a "before" and "after" of a positive example what you like to do (without scripting)?

I have an idea what's going wrong, but need a visual representation of a positive example first…

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

It looks like pretty much the same, before and after.

Screen Shot 2014-04-24 at 21.53.21.png

This is what I want to do

Screen Shot 2014-04-24 at 21.53.35.png

And this is what it does by script

Screen Shot 2014-04-24 at 22.00.12.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Without seeing your document, I can't think off-hand why it would be doing that.

This workaround should help:

function loadPagesAndOverrideElements(document, csvData) {

    // add pages defined in CSV and correct layout

    for (var i=0; csvData.numberOfRows>i; i++) {

        var masterSpread = document.masterSpreads.itemByName(csvData["master"]);

        document.pages.add();

        document.pages[i+1].appliedMaster = masterSpread;

        var allItems = document.pages[i+1].appliedMaster.pageItems.everyItem().getElements() ;

        for(var j=0;j<allItems.length;j++){

            try {

                var bounds = allItems.geometricBounds

                var obj = allItems.override(document.pages[i+1]);

                obj.geometricBounds = bounds;

            } catch(e) {

                // alert(e);

            }

        }

    }

    document.pages[0].remove();

    return document;

}

Harbs

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , Apr 25, 2014

@Harbs – hm, I'd rather store the x/y values of the objects on the master pages and move the elements to that position after overriding them.

Reason: As I see from your screen shots they contain linked images. Changing the geometric bounds will only position their container objects and not the linked image contents. (That said without testing.)

So I'd suggest the following workaround (using your code):

function loadPagesAndOverrideElements(document, csvData) {

    // add pages defined in CSV and correct layout

    for (var i=0; csvData.numberOfRows>i; i++) {

        var masterSpread = document.masterSpreads.itemByName(csvData["master"]);

       

        document.pages.add();

       

        document.pages[i+1].appliedMaster = masterSpread;

        var allItems = document.pages[i+1].appliedMaster.pageItems.everyItem().getElements() ;

        for(var j=0;j<allItems.length;j++){

            try {

                var bounds = allItems.geometricBounds

               

                //Get x and y of position:

                var xB = bounds[1];

                var yB = bounds[0];

               

                var obj = allItems.override(document.pages[i+1]);

               

                //Move object to original position:

                obj.move([xB,yB]);

               

            } catch(e) {

                // alert(e);

            }

        }

    }

    document.pages[0].remove();

    return document;

}

Without having the original files hard to say, what the real culprit is and if the workaround will work…

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Yeah. move() is probably safer.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Hi guys,

thanks for tips but none of them worked. I have uploaded my test code with @Laubenders fix on github, you can download and try it by yourselfs.

https://github.com/tomde/Indesign-Test-Script

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Uwes script will work, if you unlock your layer "Layer1".

However: I think there is something wrong with your document or with your masterPages.

Try the following test: New doc 500 x 300 px, 3 masterpages. Copy your contents from your doc in the new doc. Create 2 additional document pages and apply the masterpages by hand. Then run

var curDoc = app.activeDocument;

var allPages =  curDoc.pages;

for ( var p = 0; p < allPages.length; p++ ) {

    var allObjects = allPages

.masterPageItems;

    for ( var n = 0; n < allObjects.length; n++ ) {

        allObjects.override( allPages

);

    }

}

I would assume, that this should work with your document too, but this produce the error as well.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Hi tomas8,

Leaving aside coding wordkarounds already provided by my fellows, and the 'locked' layer problem that Kaï pointed out above, I suspect that the main issue is not in your code. Instead, we seem to have here a slightly corrupted document in terms of coordinate spaces—which may explain the unexpected shift of master items during overrides.

Considering your document in its original state, let's study the affine map of the first master page:

var page = app.activeDocument.spreads[0].pages[0],

    mx = pg.transformValuesOf(CoordinateSpaces.parentCoordinates)[0];

alert( mx.matrixValues );   // =>  1,0,0,1,-400,-300   (!)

In a document based on 500×300 the default page mapping should be [1,0,0,1,-250,-150], since the origin [0,0] of the page (i.e. top-left corner) should be expressed [-250,-150] in the spread coordinate space.

But in your case, the origin of pages is mapped to [-400,-300] so we have something of a hidden translation (dx = –150, dy = –150) that makes things go wrong under various circumstances. Note that overriden items are unexpectedly moved by (+150px,+150px) when the script invokes myMasterItem.override(myPage).

The issue is visible in IDML export as well. Extracting the spread-related XMLs you see that all page elements have the following attributes:

GeometricBounds="150 150 450 650" ItemTransform="1 0 0 1 -400 -300"

while correct values should be:

GeometricBounds="0 0 300 500" ItemTransform="1 0 0 1 -250 -150"

Whether this is an ID bug, I don't know. Since Page supports transformations the user can alter many parameters (via the Page tool, etc) without even realizing some underlying effects.

How to fix this?

(a) The best thing you can do is to edit those XML files so that all pages have the correct geometric attributes, then to re-zip the package and open the fixed IDML into InDesign to get a fresh document.

(b) I'm pretty sure that we could as well repair page matrices through scripting, but this is not as easy as I originally thought! For the time being I've not managed to get happy results by this method Perhaps my colleagues will find a way…

Once the document is clean you can use your loadPagesAndOverrideElements() function without error. (Sorry I don't know how to upload the corrected IDML file.)

BTW, here is a shorter form of your original function:

function loadPagesAndOverrideElements(document, csvData)

{

    // Assumed that layers and master objects aren't

    // locked and allow override...

   

    var i, n=csvData.numberOfRows, ms;

    for( i=0 ; i < n ; ++i )

        {

        ms = document.masterSpreads.itemByName(csvData["master"]);

        ms.pageItems.everyItem().override( document.pages.add({appliedMaster:ms}) );

        }

    document.pages[0].remove();

}

@+

Marc

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

@Marc – very interesting this all…

I did some tests with the provided files.

1. Exporting to IDML, not editing the IDML

2. Opened the IDML in InDesign CS5.5 v7.5.3

3. Ran the following script (just using your minimized code adding a line where all layers are set to locked = false)

/**

* @@@BUILDINFO@@@ 140505-1_LoadMasterSpread-Override-Test.jsx !Version! Mon May 05 2014 11:13:17 GMT+0200

*/

var document = app.activeDocument;

var csvData = {

    "master" : ["A-Master", "B-Master", "C-Master"],

    "numberOfRows" : 3

    };

document = loadPagesAndOverrideElements(document, csvData);

function loadPagesAndOverrideElements(document, csvData){

   

    //EDIT: unlock ALL layers of the document before doing anything:

    document.layers.everyItem().locked = false;

   

    //Marc Autret's minimized code:

     

    var i, n=csvData.numberOfRows, ms; 

 

    for( i=0 ; i < n ; ++i ) 

        { 

        ms = document.masterSpreads.itemByName(csvData["master"]); 

        ms.pageItems.everyItem().override( document.pages.add({appliedMaster:ms}) ); 

        } 

 

    document.pages[0].remove(); 

};

Result with CS5.5 v7.5.3: No problems. No shifting page items!

Ok. I redid the test with an edited IDML according to the values for GeometricBounds and ItemTransform you suggested.

Also no problems. That I had expected.

Next test:

Opened the unedited IDML with InDesign CS6 v8.0.2, ran the script.

Result with CS6 v8.0.2: Page items shifted.

Then I opened the edited IDML with InDesign CS6 v8.0.2, ran the script again:

NO PROBLEM (as expected).

So it seems, something has changed between InDesign CS5.5 and CS6.

I'd call it a bug…

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Re: Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

And another test:

Used the following code – the one I proposed in my answer #14 that stores the positions and move all the overridden page items to their initial positions with InDesign CS6 v8.0.2:

/**

* @@@BUILDINFO@@@ 140505-1_MOVE-TO-INITIAL-LOCATION-LoadMasterSpread-Override-Test.jsx !Version! Mon May 05 2014 11:35:18 GMT+0200

*/

var document = app.activeDocument;

var csvData = {

    "master" : ["A-Master", "B-Master", "C-Master"],

    "numberOfRows" : 3

    };

document = loadPagesAndOverrideElements(document, csvData);

function loadPagesAndOverrideElements(document, csvData) {

  

    document.layers.everyItem().locked = false;

  

    // add pages defined in CSV and correct layout

    for (var i=0; csvData.numberOfRows>i; i++) {

        var masterSpread = document.masterSpreads.itemByName(csvData["master"]);

        

        document.pages.add();

        

        document.pages[i+1].appliedMaster = masterSpread;

        var allItems = document.pages[i+1].appliedMaster.pageItems.everyItem().getElements() ;

        for(var j=0;j<allItems.length;j++){

            try {

                var bounds = allItems.geometricBounds

                

                //Get x and y of position:

                var xB = bounds[1];

                var yB = bounds[0];

                

                var obj = allItems.override(document.pages[i+1]);

                

                //Move object to original position:

                obj.move([xB,yB]);

                

            } catch(e) {

                // alert(e);

            }

        }

    }

    document.pages[0].remove();

    return document;

}

That did the trick after opening the un-edited version of the IDML with InDesign CS6 v8.0.2.

A workaround. But obviously, according to Kai, not working with InDesign CC v9.2.0. Cannot test that right now with this version.

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

@ Uwe,

Thanks, very enlightening.

So we now have a user-friendly way to fix all this:

(c) Open the IDML in ID CS5/5.5 (or even ID CS4!) then "Save as" the document (or export as IDML). The resulting file is then repaired and can be used in CS6/CC. [In CS4 this fact is obvious, since Pages haven't transform attributes at all.]

The workaround of moving shifted items by script after override() is still an option, but I consider this wouldn't actually solve the problem, I mean, under the hood.

Option (b) —that is, fixing the page matrix through scripting— remains an open question to me. I'd really like to have feedback if anyone makes progress in that direction.

@+

Marc

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

@Marc – unfortunately opening the IDML in CS5.5, saving it and open the document in CS6 or exporting to IDML from CS5.5 and opening that in CS6 will not repair the file (just tested). The only way to go is editing the IDML. Or using CS5.5 and stop there.

Oh. Another one: One option that could repair the file is opening the IDML in CS4.
Let's see…

A quick test with CS4 is showing, that this is the way 😉

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

@all – this might be a bit off-topic, but I thought the new functionality of this forum software will allow to upload files.

At least the following screenshot will suggest that:

1. I can upload a file to the Forums (or community, whatever that means):

OptionToUploadAFile.png

2. I can select a file for uploading or dropping it to the interface for uploading:

SelectAFileToUpload.png

3. But I got stuck in the middle of the process (after filling out the required form):

StuckInTheProcessUploadingAFile.png

The new forum's software is a mess…

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

@Trevor – hmm, using an emoticon like you did, generated an empty e-mail for me (I will be notified via e-mail if a new post will be added to this thread). Sorry for being OT again…

Here the mail that came in:

EmptyEMailUsingAnEmoticonByTrevor.png

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

@Marc – back from OT to the real issue behind this case…

I had another look at the provided document. One thing what was making me suspicious is the fact that the dimensions of the pages are 500 x 300 px while a look to the Pages Panel states the name for the Alternate Layout is "800 x 600 H".

The initial layout for this document was "800 x 600 px" for Digital Publishing. Later in the process this was changed to 500 x 300 px. Not by the Pages Tool, but in the GUI for the Document Setup. (A clear indication for that fact is the uniformity of Master Spread [None] to the rest of the master spreads and the first page.)

I just did that with a version of InDesign CC:

Creating a new document with 800 x 600 px and changing it to 500 x 300 px using Document Setup.

And running the script. Bam. There is it: translation!!

Now we know WHY it happened.

If we have used the Pages Tool this problem would not occur…

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

Did the same experiment with InDesign CS5.5 and CS6:

CS5.5 was ok.

CS6 was showing the issue.

So I conclude this bug (or strange behavior) sneaked in with CS6.

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Re: Override elements by script problems

Adobe Community Professional , May 05, 2014

Just showing some numbers:

var page = app.documents[0].spreads[0].pages[0];

var pageMatrix = page.transformValuesOf(CoordinateSpaces.parentCoordinates)[0];

var pageMatrixValues = pageMatrix.matrixValues;

$.writeln(pageMatrixValues+"\t"+"PageBounds:"+" "+page.bounds);

//Results CS5.5:

//NEW DOCUMENT WITH 1 PAGE: SIZE 800 x 600 px:

//1,0,0,1,-400,-300    PageBounds: 0,0,600,800

//AFTER RESIZE in GUI with Document Setup to size 500 x 300 px:

//1,0,0,1,-250,-150    PageBounds: 0,0,300,500

//AFTER RESIZE in GUI with Pages Tool on applied Masterpage A:

//1,0,0,1,-250,-150    PageBounds: 0,0,300,500

//Results CS6 and above:

//NEW DOCUMENT WITH 1 PAGE: SIZE 800 x 600 px:

//1,0,0,1,-400,-300    PageBounds: 0,0,600,800

//AFTER RESIZE in GUI with Document Setup to size 500 x 300 px:

//NUMBERS NOT CHANGED! OPPOSED TO InDesign CS5.5:

//1,0,0,1,-400,-300    PageBounds: 0,0,300,500

//AFTER RESIZE in GUI with Pages Tool on applied Masterpage A:

//1,0,0,1,-250,-150    PageBounds: 0,0,300,500

I think, this case is quite clear now.

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

Adobe Community Professional , May 06, 2014

And two screenshots to illustrate the difference of changing document page sizes in InDesign CS6 (and above):

1. "Wrong" or "dangerous" approach with the Document Setup GUI:

Was800x600now500x300_DocumentSetup_CS6.png

2. "Appropriate" approach with the Pages Tool:

Was800x600now500x300_PagesTool_CS6.png

"Wrong", "dangerous" and "appropriate" in the sense, that scripting will work as expected without moving overridden page items to their original positions.

To correct the problematic example #1, just use the Document Setup GUI and go back to the original size and change size again by using the Page Tool.

Uwe

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Override elements by script problems

This script is not full, or it's not working on InDesign CC 2014, or am I doing something wrong?

I need simple working script that will override all master page items, and fix those shifting

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...