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?
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.
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...
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.
Copy link to clipboard
Copied
Sorry, the before version is this:
the after version is this:
the text frames are all the same height and position. The text is in Greek.
Thank you very much!
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.
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
Copy link to clipboard
Copied
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();
}