Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Alphabetically order text frames?

Guest
Apr 15, 2014 Apr 15, 2014

Copy link to clipboard

Copied

I have a document with multiple pages, and each page has 5 text frames.

Is it possible to alphabetically sort those text frames thoughout the document by the heading of each individuall text frame?

TOPICS
Scripting

Views

985
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
community guidelines
Enthusiast ,
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

I would say yes, but what is the heading? > The first paragraph? If so, only english characters, lower-/uppercase, Umlaute … ? What does sort means for you ? x/y coordinates? Which values?

Please provide a example before / after.

Votes

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
community guidelines
Guest
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

The booklet is about 10 pages and it comprises of CV's of various persons. Approximately 50 persons, but the number may vary. So I want to be able to add a new person at the last page of the document, and have it automatically sorted in place alphabetically.

The heading would be the name of the person, first line of the text frame.

Hope it is clear...

Votes

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
community guidelines
Enthusiast ,
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

Not really! Where is your screenshot of the final version?

Does the frames have all the same height and position? I would think, that it is easier to sort the text when all your frames are threaded, than to sort the frames and move them over 10 pages.

Had some time at the morning. In the screen you can see my current result (frames are sorted, the values show the bounds of the frames). It would be helpful if you provide a idml with those threaded frames.

Now it is evening here. So the next version will come surely tomorrow.

Bild 2.png

Votes

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
community guidelines
Guest
Apr 17, 2014 Apr 17, 2014

Copy link to clipboard

Copied

Sorry, the before version is this:

8.jpg

the after version is this:

2.jpg

the text frames are all the same height and position. The text is in Greek.

Thank you very much!

Votes

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
community guidelines
Enthusiast ,
Apr 17, 2014 Apr 17, 2014

Copy link to clipboard

Copied

hm, hm. I’m afraid, that my sort-routine will only work with englisch-text at the moment. Since I never did anything with greek text, I have no idea, how greek text can be sorted. But maybe others can dive in here.

It is even not clear, how the alternate pictures are created. Please provide your example before/after without the pics as idml. I wil try to write something that will move the frames, after the text is sorted.

Votes

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
community guidelines
Enthusiast ,
Apr 17, 2014 Apr 17, 2014

Copy link to clipboard

Copied

Hi Kia,

Please help for me for the above request:

I am just learn myself to complete this, but fail to do it.

Below is my coding:

var myDoc = app.activeDocument;

strArray = new Array();

var myStories = app.activeDocument.stories.everyItem().getElements();

for(i=myStories.length-1; i>=0; i--)

{

    var TF = myStories.textContainers;

    for(k=TF.length-1; k>=0; k--)

    {

    strArray.push(TF.contents + "\t" + TF.geometricBounds)

        }

    }

var mySort = strArray.sort().join("\r")

alert("mySort: " + mySort)

struggling here only....

Please help to complete this task.

My required output is, just sort out text frames one by one in alphabetical order.

Regards

Siraj

Votes

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
community guidelines
Enthusiast ,
Apr 17, 2014 Apr 17, 2014

Copy link to clipboard

Copied

LATEST

I’m not sure, if this is helpful so far, but this is what I have at the moment:

var curDoc = app.documents[0];

var curPage = curDoc.pages[0];

// das Ergebnis der sortierten Liste

var sortedTextFrames = getTextFramesAndContent();

// den String vorbereiten

var msg = "";

// eine Schleife durch das Ergebnis

for ( var s = 0;  s < sortedTextFrames.length; s++ ) {

    msg += "Rahmen-ID: " + sortedTextFrames[0].id + "\r" +

    "Erster Absatz: " + sortedTextFrames[1] +

    "Y-Position: " + sortedTextFrames[0].geometricBounds[0] + "\r\r";

}

alert("PageItems sortiert\r" + msg);

// gibt alle Textrahmen und deren Inhalt zurück

function getTextFramesAndContent() {

    var list = new Array();

    // alle Textrahmen der aktuellen Seite

    var pageTfs = curPage.textFrames;

       

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

        var curTf = pageTfs;

        // Inhalt des ersten Absatzes im jeweiligen Rahmen

        firstPara = curTf.paragraphs[0].contents;

        // den Rahmen u. ersten Absatz in das Array aufnehmen

        list.push( [curTf, firstPara] );

    }

    // die Liste seitenweise sortieren

    list.sort( case_insensitive );

    return list;

}

function case_insensitive ( a, b ) {

    return a[1].toLowerCase() > b[1].toLowerCase();

}

Votes

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
community guidelines