Move Pages in the Document (according to width)

Hi all

First of all, tons of thanks to all the members of the Forum.

Help and guide me much in Javascript.

Request:

1. in the Active Document

2. collect full width Pages

3 sort according to the width

4 move pages according to the width (minimum to maximum) //Here is the problem, please help...


Output current Script (LEFT) & exit necessary (to the RIGHT):


Screen Shot 2015-06-06 at 2.06.39 PM.pngScreen Shot 2015-06-06 at 10.29.02 AM.png

The coding is below:

var destination_doc = app.activeDocument;
destination_doc.documentPreferences.allowPageShuffle = true;
destination_doc.spreads[-1].allowPageShuffle = true;     //
var myWidthArray = new Array(); 

var myPages = app.activeDocument.pages;   //Doubt, pages or spread
for(p=0; p<myPages.length; p++)
{
    var myDocument_Width = Math.round(myPages[p].bounds[3]-myPages[p].bounds[1]);
    var myPage_Name = myPages[p];
    //var myPage_Name = myPages[p].name;
    var myReq = {w:myDocument_Width, d:myPage_Name};
    myWidthArray.push(myReq)
    }
alert("FirstWidth: " + myWidthArray.toSource()); 

var myPoints = myWidthArray;  
myPoints.sort(function(a, b){return a.w * 1-b.w * 1}); 
alert("myPoints: " + myPoints.toSource()); 

for(var k=0; k<myPoints.length; k++) 
{ 
     var sourceSpreads = myPoints[k].d; 
     alert(sourceSpreads);
     sourceSpreads.move(LocationOptions.AT_END, app.activeDocument.pages.item(-1));     //I think here is the problem
     } 

Thanks in advance

Siraj

Hi Cognet,

I had a look at your snippet and it leaves a little room for improvement.

It is a different approach. The n is right there to see how many times the spreads are being told to move.

I put code snippets in a doScripts to make it easier to compare.

In the case below your code snippet is "moving" the "spreads" 8 times, and this is true even if you rerun the code snippet.

It should only move 2 pages.

HTH

Trevor

My method

app.doScript (f, ScriptLanguage.JAVASCRIPT, undefined,UndoModes.FAST_ENTIRE_SCRIPT);
function f () {
    var myPages, mySortedPages, l, n = 0;
        mySortedPages = (myPages = app.activeDocument.pages).everyItem ().getElements ().slice(0).sort(function (a,b) {return (a.bounds[3] - a.bounds[0]) - (b.bounds[3] - b.bounds[0])});
        l = myPages.length;
        while (l--) { if (mySortedPages[l].documentOffset != l) mySortedPages[l].parent.move(LocationOptions.AFTER, myPages[l].parent) && n++; }
        alert(n + " page moves")
}

Below is your method just with the passage of the page changed to spreads move and a warning of the spread move calls

app.doScript (f, ScriptLanguage.JAVASCRIPT, undefined,UndoModes.FAST_ENTIRE_SCRIPT);
function f() {
   var doc = app.activeDocument;
    var pages = doc.pages;
    var pagewidth = [];
    var n = 0;
    for(var i=0;i 
         

Tags: InDesign

Similar Questions

  • When I versteckte UN of a page of the document, it parts of four is scanned en! Comment to solve the probleme.sur windows 7 pc and printer epson sx 105

    When I versteckte UN of a page of the document, it is scanned in 4 parties.comment solve this problem. PC windows 7 epson sx105 printer

    Hello

    You asked your question in the English version of the Microsoft Community. Please could you click on the globe icon to the world (change region) at the bottom left of the screen and then choose your preferred language. Now ask you question once again.

    If you can't find a suitable language, please go here:

    http://support.Microsoft.com/common/international.aspx

    for other international support options.

    Thank you.

  • Dreamweaver beginner 2015 CC [how you define the page of the document with the same dimensions?]

    Maybe this is a stupid question.  How do you define the page of the document to exactly what you design.  I need to create an ad by e-mail to the 800px 650px.

    There are no stupid questions, answers all simply stupid. I hope that this will not be one of these responses.

    The short answer is that you don't set limits to a document, such as e-mails, Web sites or other. An email to read on an iPhone will have completely different dimensions for a reading on a computer screen. Mesaages read in Outlook will behave different to those read in a text format.

    Unless you know your audience and the device they are using, you must keep the liquid paper. For more information, see here http://webdesign.tutsplus.com/articles/creating-a-simple-responsive-html-email--webdesign-12978

  • How can I get the electronic signature on the same page as the document.

    Whenever I have send a document for Adobe Acrobat DC using the sign and send the signature always returns on a separate page.  Can this be fixed so the signature put on the signature line of the document, or at least at the bottom of the last page of the document?

    Hi lotus4270,

    Would like to inform you that, if the document has a field, the user can sign with the material. If there is no field, then it will appear at the bottom & if the page size is large then in this case it will appear in the separate page at the end.

    Kind regards

    Christian

  • How can I get my Indesign script to apply to all pages in the document?

    My (java) script below apply only to the first page of the document. How can I get to apply to all pages in my document? What Miss me? Thank you.

    script:

    myDocument = app.activeDocument

    with (myDocument.pages.item (0) .marginPreferences) {}

    columnCount = 1;

    columnGutter can be a number or a measurement string.

    columnGutter = "0";

    low = '0 '.

    When document.documentPreferences.facingPages == true,

    "left" means inside; means 'right' on the outside.

    left = '0 '.

    right = "0".

    Top = '0 '.

    inside = "0".

    }

    Hello

    You can browse all the pages.marginPreferences:

    var
      myDocument = app.activeDocument,
      allPagesMaPref = myDocument.pages.everyItem().marginPreferences,
      curPageMaPref;
    
    while ( curPageMaPref = allPagesMaPref.pop() )
      with (curPageMaPref) {
      columnCount = 1;
      //columnGutter can be a number or a measurement string.
      columnGutter = "0";
      bottom = "0"
      //When document.documentPreferences.facingPages == true,
      //"left" means inside; "right" means outside.
      left = "40"
      right = "0"
      top = "0"
      inside = "0"
      }
    

    Jarek

  • When I export a PDF from Indesign CS6 (PDF1A), the first page of the document is blank.  Why?

    When I export a PDF from Indesign CS6 (PDF1A), the first page of the document is blank.  Why?

    Do not fix PDF 1A errors?

    Here is my screenshot of indesign and acrobat.  The first page is empty, the second page is not.  Why only the first page?

    Any help is very appreciated!  Thanks in advance!

    Screen shot 2012-12-10 at 11.42.29 AM.png

    Adobe strongly recommends use of PDF/X-4, which retains direct management transparency and color all the way to the INVESTIGATION period.

    PDF/X-1a is indeed antiquated for any content that uses anything other than CMYK + spot color or transparency.

    All modern PDF workflow software supports PDF/X-4. If you are printing to a PostScript RIP, Acrobat Pro (version X and XI) can print PDF/X-4 of tears (or printers) pretty well.

    -Dov

  • Keep old links and add new links to the title page of the document

    I was given an interactive pdf to update. The work on the title page insrtucts the Viewer to click on a highlighted product to a product page in the document... The revised document that ancient works of art and the links will remain in the same place, but other products have been added that will be tied to additional product pages. So I have to change the basic art, is it possible in Acrobat to replace the old work base with new art without distrubing the former basic links?

    Links are a form of markup. Create the page PDF of the work. Open the old PDF (or better a copy), then replace pages allows you to replace the basic document page. The markup should not be affected.

  • How can I move pages from one document to the other without merger of paragraph styles?

    I want to create a singular indesign file of 2 separate documents, which allows me to make an interactive PDF of it.

    However, when you move pages from one to the other, it seems that when each document has a paragraph style with the same name, they merge. The problem is that text is then adjusted if the styles do not match completely.

    Is there a way to merge the documents without any formatting changes?

    Create a Style group in each document and move all styles in this file. Give each document a different name. Do it with all kinds of styles: paragraph, character, objects, tables and Cell Styles. Then you can sort them later in the merged document what you do with these styles.

  • applying master pages to the pages of the document, can't drag any page icon that the hand tool loose when I move my mouse.

    I am a student at the University of anchorage Alaska system.

    I am a student in inDesign adobe cs6 with the classroom in a book, I'm going through the book and have a problem with a long head.

    When mastering pages and I'm trying to drag and drop the page icon mastered to pages of documents icon the little hand loose when I move my mouse.

    Similarly, when I drag and drop a page icon to another icon of documents documents hand let go when I move my mouse.

    I restarted saved and recreated my documents, that nothing seems to solve the problem

    Help!

    I am running an hp Pavilion AMD APU A10 - 5750M with clocked at 2.5 ghz, Radeon HD graphics card

    I have 8 GB of ram 64 bit op X 64 based processor, I have a 750 GB drive with more than 60% free space

    I believe that my system can handle CS6

    win 8.1 current as of 02/05/2015

    My problem was that when I take and drag the page contained in the pages Panel icon, then place the cursor on the page icon of the document I wanted to apply mastering too.
    It did not show the hand with the icon of the master, or the border turn dark, waiting for the fall to apply the format of mask, hand became the pointer.

    I followed a suggestion to viola "remove-reboot-re install - restart" it works now!

    Unknown problem with the first installation

  • Numbering of the pages of the Document pages 5.6.2 problem

    How do hide you the page # on the first page of a document, then start by #2 on page 2? The aide said only button how to hide all the page numbers in a book - help. The drop-down menu offered inset only insert page number in my beginning of header with page 1. If I deleted that, went to page two and inserted a two, he showed that two page one as well - infuriating! Word can do that, and I think that I found a way to Pages in the past, but my memory is perhaps in error.

    Thank you

    Click on the Page > toolbar > Document > Section > headers and footers > hide on the first page of article

    or

    Insert the break Section at the bottom of Page 1 > click in the Page 2 foot of page/header > Menu > insert > Page number

    Click on the Page > toolbar > Document > article > the page numbering > numbering > start: 2

    Peter

  • has got HP Photosmart C4180.when I scan more than 1 page of the document, it will not save pages as 1 file

    I have HP Photosmart C4180 printer and when I scan 1 page of a document, it will save all the pages into a single file? I wonder why?

    ozzyuk,

    Thanks for the information. I would like you to go ahead and start here: how Scan: Windows 7, remember that you must have the full feature software and drivers installed and use the HP Solution Center. Once on this page, please select the way to scan with HP software and select the multi documents page.

    I hope this helps!

    Thanks again,

  • HP Officejet All In One 2620: Page with the document creation date

    When I go to print a document, I get a page of head showing the file name, directory, template etc which is a waste of paper! How can I stop this impression

    What operating system? What program are you printing from?  If you print from 2016 Word click file, view, Options, Print Options, and uncheck the Print Options of the Document, OK.  Other versions of Word would be similar.

  • Move pages from one document to another

    How to take a page of a document in the thumbnail and drag it to another document?

    There is a free trial of Acrobat (Pro) that you can use for 30 days.

    After that, you will need to buy or join.

  • Login page with the notification according to the username (like the login page of LinkedIn)

    Hello!

    I would like to implement the feature (as is on the login page of LinkedIn) where according to saved cookie (username) there are certain notifications (messages, etc.).

    How to make a such hing Apex 4.2? At least some advice what should be the right direction.

    BRG

    Damir

    See the Notification icon with the number of pending notifications

  • Check the number of continuous Page in the Document

    Hi all

    It is possble to check the number of continuous page in the active document.

    Problem is due to the use of several "number and Sections options" in the control panel pages F12.

    No error: alert ("Pass")

    If an error in the sequence of folio: alert ("Fail")

    Could someone please help for my application.

    Currently replace all elements of the master page by using the following script

    main();
     function main() {
        var doc = app.activeDocument,
            i, l, page, j;
            
        for (i = 0; i<  doc.pages.length; ++) {
            page = doc.pages[i];
            if (page.appliedMaster !== null) {
                for (j = 0; j< page.appliedMaster.pageItems.length; j++) {
                    try {
                        page.appliedMaster.pageItems[j].override(page);
                    } catch(e) {}
                }
            }
            page.pageItems.everyItem().detach();    
        }
    }
    
    

    Thanks in advance

    Beginner_X

    Check the code below

    main();

    main() {} function

    var doc = app.activeDocument,

    i, l, page, j;

    pageNumber = 0;

    for (i = 0; i<  doc.pages.length;="" i++)="">

    page = doc.pages [i];

    pageNumber ++

    Alert (page.name)

    If {(page.name is pageNumber)

    Alert ('pass')

    }

    else {}

    page.name = pageNumber

    Alert ("fail")

    }

    }

    }

Maybe you are looking for

  • Adding a port series HP xw6600, xw8600, and other workstations

    Based on some advice from Dan_in_WGBU (which is a HP engineer and an excellent source of information in this forum), here's how to add a serial port backplane HP.  To access a serial port still can be very useful for some projects. As is done with ma

  • Windows XP suddenly shows not authentic

    I know there have been other discussions on this, but could someone help me please?  I installed the windows updates today (about 25 of them) and when I restarted the computer it is a black screen and says that my copy of Vista is not authentic.  I a

  • Where can I post?

    This specific forum post questions about software MyDell of diagnosis for my desktop XPS 8500 (running Windows 8.1)? Thank you.

  • Linux on M52 8113 D1U

    XP installs and runs very well. When I try and install Linux (Fedora Core 10 or 12, Ubuntu) I get sporadic crashes during installation. Aybody got Linux installation on this machine or any recommendation for the core or the bios options? I suspect ev

  • What is the difference between win 7 pro DSP OEI DVD and Full pack?

    I bought a Win 7 pro 32-bit provider. The full name is 'Win Pro 7 x 32 English 1pk DSP OEI SPI'. I have no idea to distinguish this license product OEM or full license.