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

[JS] Toc Convertion

Enthusiast ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Good morning all,
Is there a command to convert a text block containing a Table of Contents to pure text, there I still have the TDM update option?
Thank you

Liphou

 

Bonjour à tous,

Exit-il une commende pour convertire un bloc texte contenent une Table des matière en pur texte, là, j'ai toujours l'omption mise à jour de la TDM?

 

Merci

TOPICS
Scripting

Views

539

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

correct answers 1 Correct answer

Community Expert , Jun 08, 2021 Jun 08, 2021

Sorry. I still do not get it.

What exactly do you mean by: "I have the conversion in cross reference" ?

 

Ok. Let's assume you want an exact duplicate of your TOC's text frames and let's assume you have an idea how you can access one of the frames of your TOC, you could run a code like the one below where I assume that a text frame is selected:

 

var originalStory = app.selection[0].parentStory;
var textContainers = originalStory.textContainers;
var dupFrames = [];

for( var n=0; n<textContainer
...

Votes

Translate

Translate
Community Expert ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Hi Liphou,

I'm a little confused. Do you mean you need a duplicate of a TOC story that you could update?

 

Or do you need a duplicate of a TOC that could not be updated?

In this case simply duplicate the frames holding the TOC and thread them in the right order.

Or duplicate the text of a TOC Story to a new text frame you added to the document.

 

Regards,
Uwe Laubender

( ACP )

Votes

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
community guidelines
Enthusiast ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Thank you Laubender,
I have the conversion in cross reference but as long as it is a table of contents it is not possible.
The table of contents is on several pages.
Bat
Liphou

 

Merci Laubender,

Je dois la convertire en referece croisé mais tant qu'elle est une table des matière c'est pas possible.

La table des matière est sur plusier pages.

Bàt

Liphou

Votes

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
community guidelines
Community Expert ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Sorry. I still do not get it.

What exactly do you mean by: "I have the conversion in cross reference" ?

 

Ok. Let's assume you want an exact duplicate of your TOC's text frames and let's assume you have an idea how you can access one of the frames of your TOC, you could run a code like the one below where I assume that a text frame is selected:

 

var originalStory = app.selection[0].parentStory;
var textContainers = originalStory.textContainers;
var dupFrames = [];

for( var n=0; n<textContainers.length; n++ )
{
	dupFrames[n] = textContainers[n].duplicate();
	
	if( n == 0 ){ continue };
	
	dupFrames[n-1].nextTextFrame = dupFrames[n];
};

var dupStory = dupFrames[0].parentStory;

 

Regards,
Uwe Laubender

( ACP )

Votes

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
community guidelines
Enthusiast ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Thank you Laubender,
It works very well.

We have so much to make adaptations to the table of contents, that each update, we have to redo them, a lot of wasted time.
And finally, I'm going to make a script that creates cross-references on just the folio of the table of contents and of course in a book 😉

Thank you very much a step taken

good to you

Liphou

 

-------------------- Traduction

 

Merci Laubender,
Cela fonctionne très bien.

Nous devons tellement à faire d'adaptations à la table des matière, que chaque mise à jours, on dois les refaire, beaucoup de temps perdu.
Et final, je vais faire un script qui cree des réference croisé sur juste sur les folio de la table des matières et biensur dans un livre 😉

Merci beaucoup un etape franchie

bien à toi

Liphou

Votes

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
community guidelines
Enthusiast ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

je fais un petit controle en plus :

 

if (app.selection[0].parentStory.storyType == StoryTypes.TOC_STORY) {

        var originalStory = app.selection[0].parentStory;
        var textContainers = originalStory.textContainers;
        var dupFrames = [];

        for ( var n = 0; n < textContainers.length; n++ )
        {
            dupFrames[n] = textContainers[n].duplicate();
            
            if ( n == 0 ){ continue };
            
            dupFrames[n-1].nextTextFrame = dupFrames[n];
        };

        var dupStory = dupFrames[0].parentStory;
        app.activeDocument.hyperlinks.everyItem().remove();
}

 

Votes

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
community guidelines
Enthusiast ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

J'ai rajouté cette ligne aussi :

app.activeDocument.hyperlinkTextSources.everyItem().remove()

Votes

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
community guidelines
Community Expert ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

Oh. I would not dare to to this.

You would also remove hyperlinkTextSources that are not related to the TOCs.

 

Regards,
Uwe Laubender

( ACP )

Votes

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
community guidelines
Enthusiast ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

LATEST

Yes, while the source is there, I cannot create a cross reference instead, here the TOC is in a separate file so I can delete all of them without too much problem.

 

Oui, tanque la source est là, je ne peux créer une réference coisé à la place, ici le TDM est dans un fichier a part donc je peux tous suprimé sans trop de problème.

 

Tanks

Liphou

Votes

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
community guidelines
Community Expert ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

For all readers who wonder, this thread is tied to this one:

 

[JS] Toc makeAnchor
Liphou, Jun 07, 2021
https://community.adobe.com/t5/indesign/js-toc-makeanchor/td-p/12095999

 

Regards,
Uwe Laubender

( ACP )

Votes

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