Create TOC javascript using paragraph style

Hi,
i want to create javascript for TOC in new indesign document or book. but i want to use input style for paragraph styleHi,

"It didn't work for me" doesn't work for me. Always, always, always, state why it doesn't work for you.
Did you try to use it, but could not get it to work?
Or, do you need to do something special that the built-in function does not do?
It should not be extremely hard to make a javascript version that does (roughly) the same. You could try something like this:
For every paragraph style you want to include (most likely all sorts of headings),
Search for all occurrences, and store the text, its page number, and (important!) its story offset in an array.
You need the text because that's what will appear in the TOC.
You need the page number because, well, that's what the TOC is for :-)
Most important: you need the story offset so you can reconstitute the original order of the headings. You can only search for one level of heading at a time, so without sorting, you would get "Heading 1 -- Heading 1 -- Heading 1 -- Heading 2 -- Heading 2 -- Heading 2" (etc.)
When you have gathered all of the information for your entire book, sort on story offset. (I forgot, it's for a Book, right? You need to store a document id as well, so you can sort throughout multiple documents.) (See Ed.)
Then write out every text in the right order, followed by its page number.
The IndexMatic script that Marc points out should already contains lots of the logic described here -- esp. searching and storing page numbers.
[Ed.] Thinking about it, a Book (multiple documents) should *not* cause any problems, and you don't need to know in which document some text was found. Simply sort the paragraphs on their page number; only when these are the same for more than one paragraph, sort just these on their Story Offset. Logically, there should not be two headers with the same page number in two different documents.

Similar Messages

  • How to find paragraphs by using paragraph style name?

        How to get the Paragraph style UIDRef from paragraph style name.
    To find the paragraphs using Paragraph style i want UIDRef of paragraph style.Can some one help me..,

    IDocument *doc = GetExecutionContextSession()->GetActiveContext()->GetContextDocument();
    UIDRef ws = doc->GetDocWorkSpace();
    InterfacePtr<IStyleGroupManager> paraStyleNameTable(ws, IID_IPARASTYLEGROUPMANAGER);
    PMString styleName("someStyle");
    UID paraStyleUID = paraStyleNameTable->FindByName(styleName);
    if(paraStyleUID != kInvalidUID)
         //We found the style
         UIDRef styleRef(doc->GetDataBase(), paraStyleUID);

  • Create TOC javascript for indesign book

    Hi friends,
    i am new to indesign javascript. i want to create a javascript for TOC indesign book using paragrph style
    could anyone help me. i am strugling long time.

    "It didn't work for me" doesn't work for me. Always, always, always, state why it doesn't work for you.
    Did you try to use it, but could not get it to work?
    Or, do you need to do something special that the built-in function does not do?
    It should not be extremely hard to make a javascript version that does (roughly) the same. You could try something like this:
    For every paragraph style you want to include (most likely all sorts of headings),
    Search for all occurrences, and store the text, its page number, and (important!) its story offset in an array.
    You need the text because that's what will appear in the TOC.
    You need the page number because, well, that's what the TOC is for :-)
    Most important: you need the story offset so you can reconstitute the original order of the headings. You can only search for one level of heading at a time, so without sorting, you would get "Heading 1 -- Heading 1 -- Heading 1 -- Heading 2 -- Heading 2 -- Heading 2" (etc.)
    When you have gathered all of the information for your entire book, sort on story offset. (I forgot, it's for a Book, right? You need to store a document id as well, so you can sort throughout multiple documents.) (See Ed.)
    Then write out every text in the right order, followed by its page number.
    The IndexMatic script that Marc points out should already contains lots of the logic described here -- esp. searching and storing page numbers.
    [Ed.] Thinking about it, a Book (multiple documents) should *not* cause any problems, and you don't need to know in which document some text was found. Simply sort the paragraphs on their page number; only when these are the same for more than one paragraph, sort just these on their Story Offset. Logically, there should not be two headers with the same page number in two different documents.

  • Creating Space after a Paragraph Style

    Okay, all, this may sound weird. All I want to do in CS4 is have an extra 4 pt of space after a particular paragraph style. Specifically, my paragraph style, Body Text, already has "space after" specified at 3 pt. Fine. But, for example, when I have three paragraphs of just this style, I want the three paragraphs separated by an additional 4 pt of space. (There is no consistency in documents when this situation occurs.)
    At first, I thought it might be possible to do this via a nested character style. Nope. Back in FrameMaker, I used to do this manually, whenever I wanted extra space. My trainers would add paragraph tags (ugh).
    Still a newbie...
    Thanks!
    Lizbeth

    Kenneth C. Benson wrote:
    Maybe I'm really missing your meaning here. When I override a style setting to get more space below, I add space below the *paragraph*. I don't adjust anything about the last line. This is no different in Framemaker. In Framemaker, you can add space above or below a paragraph, either as part of a style (what FM calls a "format") or as a style override. You don't "adjust the last line of a paragraph" in either program.
    There's one important difference between FrameMaker's paragraph
    spacing and most other DTP or WP tools: Space between FM paragraphs is
    NOT ADDITIVE. Space below a paragraph is not added to space above the
    following paragraph. In FM, the larger space wins. (I think Ventura
    has this feature also, or perhaps has the option for additive or
    larger-one-wins.)
    If the issue is to make inter-paragraph spacing work non-additively
    like FM, please file a feature request for this as an option, at:
    www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    EDIT: The forum was unavailable for a while, and my email response was bounced. By the time I discovered the rejected mail, I saw Lizbeth's mention of having used Based-on paragraph styles. Probably the based-on style caused the mysterious behavior. The based-on property style information is only visible in the define/modify style dialog box. I'm going to enter a feature request for an indicator for the based-on property that will appears wherever a style's name appears, and, if possible, displays the name of the based on paragraph, character, and object style. Master pages do show the based-on master letter on the page icons in the pages panel, but they lose their own letter. I'll also ask for this feature. 
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • TOC for ePub Paragraph style editing

    I'm trying to figure out if InDesign can allow us to editor the dynamic table of contents. What we have is basically this:
    Chapter number (unique paragraph style)
    Chapter title (unique paragraph style)
    First paragraph (unique paragraph style)
    We want the ToC that gets pulled up in a eBook reader to show this:
    Chapter 1: Chapter Title
    Chapter 2: Chapter Title
    Right now, InDesign seems to only export each as a specifc paragraph style, without setting them on the same line side by side. We get stuck with:
    Chapter 1
         Chapter Title
    Chapter 2
         Chapter Title
    Does anyone know of a way to export the ePub so it's what we want rather than this hirarchically broken way?

    This TOC issue has bugged me for years.
    I have been able to come up with certain workarounds, but only when my physical (print) TOC just happens to be set up exactly as I would like it displayed in the ePub (this is not always the case).
    It would be wonderful if there was a way for us to better control how the TOC info is output when exporting to ePub.
    For now, the fastest and easiest way to deal with this issue (for me anyway), is to manually update it in the ePub file after export.
    Cheers,
    Ron

  • Help using paragraph styles...

    When I create a paragraph style from a bit of text, the paragraph style box picks it up, and when the preview is selected it looks perfect, then when I press apply, it completely messes up. The text downsizes one, and sometimes it turns itself into itallics.
    Does anyone know the reason why this is happening?
    Many Thanks
    Sam

    It sounds like a corruption issue. Does it happen in a new file, too, or just in this current file?
    If it's just this file, see Remove minor corruption by exporting, otherwise, try trashing the prefs (see Replace Your Preferences).

  • Indesign Crashing When Using Paragraph Styles

       Heres a paste of the report...
    http://pastebin.com/x8X7PfSs
    I'm still having an issue with my xrefs not displaying the proper chapter number, and now when I go to edit xref defs, the xref def is not listed and a the panel is switching the definition to an arbitrary or random def. This occurs when I the pencil (edit def) button.
    Not so much a question, just a call for feedback, suggestions, or possibly sollutions. I'm in the middle of a 120+ page user manual spread across 20 chapters.

    Not surprisingly that crash looks like it's related to the Hyperlinks panel.
    For those of us not sure what your other issue was, or if it's realted, could you provide full details here of what you are doing and what happens?

  • Problem changing and creating paragraph styles in Pages

    When using paragraph styles I come up against several problems that I haven't been able to figure out with the help menu:
    1. When I change a para with the style list it doesn't change the para to the chosen parameters. It changes for instance the font but not the size. How do I make sure that the chosen text gets changed completely?
    2. When I want to create a new style from selection it does not create a style that turns up in future lists. I only get to choose what is already somewhere in the text I am writing and what seems to be a default list that shows up with every new document. To change to something else I have to find a text that has the format I want, copy a piece of it, put it into the text I am working on and then try and change the paragraph style. How can I make sure that I have the styles I want at my disposal whatever I am working on? Can I somehow edit the choices in the style drawer?
    3. When looking at the help menu, this is the beginning of an instruction:
    +To apply a style to one or more paragraphs, select the paragraphs you want to change, or select an entire text box, table, table cell, or shape that contains text. Click the Paragraph Styles button in the format bar, and then choose the style you want to apply+
    Now, where do I find the paragraph styles button and where is the format bar? I clicked my way through numerous drop down menus but haven't found what this is referring to.
    Would be grateful for any hints, and please keep your explanations simple enough. I need instructions for dummies Thanks in advance!

    ravenowl wrote:
    When using paragraph styles I come up against several problems that I haven't been able to figure out with the help menu:
    1. When I change a para with the style list it doesn't change the para to the chosen parameters. It changes for instance the font but not the size. How do I make sure that the chosen text gets changed completely?
    Double click on the style name in the styles drawer to completely force the style onto the selected text. This will however eliminate any bolding, italics, underlining etc.
    2. When I want to create a new style from selection it does not create a style that turns up in future lists. I only get to choose what is already somewhere in the text I am writing and what seems to be a default list that shows up with every new document. To change to something else I have to find a text that has the format I want, copy a piece of it, put it into the text I am working on and then try and change the paragraph style. How can I make sure that I have the styles I want at my disposal whatever I am working on? Can I somehow edit the choices in the style drawer?
    To add a style to the Styles Drawer, format your text, then click on the little red triangle next to the style in the drawer and choose New from selection giving it a name.
    You can also change the name of the style by right clicking on the name and selecting Rename. This is not always available as some names are reserved.
    Each document has its own definitions of the styles. You can import Styles from other documents:
    +Menu > Format > Import Styles… > Browse to a document with the styles and select those you want to copy over+
    3. When looking at the help menu, this is the beginning of an instruction:
    +To apply a style to one or more paragraphs, select the paragraphs you want to change, or select an entire text box, table, table cell, or shape that contains text. Click the Paragraph Styles button in the format bar, and then choose the style you want to apply+
    Now, where do I find the paragraph styles button
    It is the reversed blue P on the Toolbar, also +Menu > View > Show Styles Drawer+
    and where is the format bar?
    I assume you are referring to the toolbar at the top of the window.
    I clicked my way through numerous drop down menus but haven't found what this is referring to.
    Would be grateful for any hints, and please keep your explanations simple enough. I need instructions for dummies Thanks in advance!
    I suggest you download and read the Pages09_UserGuide.pdf under the Help menu.
    Peter

  • Paragraph Styles not showing up in TOC window

    I am using a template that uses paragraph styles ( when I click on a heading line the corresponding Heading 1 becomes selected in the paragraph styles draw) yet no paragaph headings show up in the TOC window.
    thanks for any help

    Thank you.
    The problem is that sometimes they will display, and sometimes they 
    won't (within the same document).
    I finally got them to show up, but then if I re-open they may (or may 
    not) disappear.

  • Create numbered list paragraph style

    Hi;
    I have Pages version 5.2 installed on my MacPro 10.9.4.
    I am trying to create a numbered list paragraph style w/o success; since the numbered list attribute isn't being remembered as part of the paragraph style.
    Next time i mark something as belong to the paragraph style i created, it shows w/o a number (numbered list isn't set).
    What am i doing wrong?

    Using Pages 5.2.
    Just one of the over 110 missing features:
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=424&sid=571e57a6fbee e115ddb08955041013cc&mforum=iworktipsntrick
    Use Pages '09 if you have it.
    Peter

  • Paragraph styles dialogue is empty. I'm unable to load or create new styles and have them show up.

    I've used paragraph styles in Indesign CS4 since 2009 and yesterday (6-10-14) I noticed the paragraph styles dialogue was empty. I figured somehow I must have accidentally deleted or cleared them. I then proceeded to attempt loading them from another document. After "Loading Paragraph Styles..." via the drop-down in the upper right corner of the dialogue box nothing showed up.
    I then proceeded to create a new style it to never appeared in the list—it remains empty.
    Any ideas?

    Delete InDesign’s preferences.
    Troubleshooting 101: Replace, or "trash" your InDesign preferences

  • Using "Next style" with the same paragraph style for more than one paragraph

    Hi.
    I have been using paragraph styles with the "next style" option, it's a huge help. But I need a bit more. So I have the following paragraph structure: ABCCCABCCCAB...
    I defined paragraph styles for each kind of paragraph, then in paragraph style A, I added paragraph style B as the next style, and so on. However, when I get to paragraph style C I reach a dilemma. Should I define the next style as the same, or define three paragraph C styles (C1, C2 and C3), link them to each other with next style, and then loop the C3 style into the A style again?
    My hope is that there is a way, something like the nested style options, that allows me to define that style C should be used for 3 paragraphs and then the next style becomes style A again.
    Thanks.

    You just need two styles, almost identical, you can duplicate one.  The only
    difference is one has the next paragraph c and one has the next paragraph
    a.  After that I don't see the problem.

  • Paragraph Style to control paragraph breaks?

    Hi All,
    How do you add paragraph breaks using Paragraph Styles?  I'm sure the answer is pretty obvious, but I don't have the vocabulary that comes with a layout/print background so I'm probably looking at the setting but not knowing it.
    What I'd like to do is create a paragraph style that inserts an extra paragraph break (return) at the end of a paragraph so that instead of something like this:
    Voluptat vitis dolorro to molupta tempos autet etum alis res int re voloriorest maio. Ulpa as debit prae vellaut ommoloratur susdamus endandit, qui sandesci corerspiet quis essequid evenis periorp oriberspidit illab in cum hit poratem porpore periam ipic to totaess imintiam quia alicid ullabo.
    Erspernate nostiis dolorem re in poria ipsum volum none nus.
    Upti aut aut pore as mod qui cusaera estiatest voloreni re num alignatio. Et poremped qui nemquossunte ducilignatem fugiand untionsendia aut ut quodis endant.
    Pici doluptam et re sandebis impelit asitate voluptate parum ilibustrume non resequo diciur?
    ....the paragraphs look like this:
    Voluptat vitis dolorro to molupta tempos autet etum alis res int re voloriorest maio. Ulpa as debit prae vellaut ommoloratur susdamus endandit, qui sandesci corerspiet quis essequid evenis periorp oriberspidit illab in cum hit poratem porpore periam ipic to totaess imintiam quia alicid ullabo.
    Erspernate nostiis dolorem re in poria ipsum volum none nus.
    Upti aut aut pore as mod qui cusaera estiatest voloreni re num alignatio. Et poremped qui nemquossunte ducilignatem fugiand untionsendia aut ut quodis endant.
    Pici doluptam et re sandebis impelit asitate voluptate parum ilibustrume non resequo diciur?
    Thanks!

    What you want is to have the space before and/or the space after set to add that space.
    The amounts I use depend on the baseline grid (if used) so that the amounts of space before/after add up to the baseline grid amount.
    Mike
    Message was edited by: MW Design
    Added screen shot

  • Reflection applied to character/paragraph style?

    Can anyone point me in the right direction to create a character or paragraph style for using the web 2.0 reflection on text? example below...
    Thanks!

    Apologies not necessary. That previewColor property has been a mystery for quite some time, and when I finally found out what it is supposed to do, it seemed to be so bug-ridden that I quickly steered away from it and I gave up attempting to make any sense of it. But your script just avoids those bugs popping up!
    As I said in the IDS post: it's rather sad the Adobe team gave up on further developing this great hidden feature into a full one; and it's downright worrying that they left that legacy code in CS5 and later, so it could get infested with all those nasty little bugs. It leads me to think: how many more 'dead' code is there, in CS5, 5.5 and now in CS6? Could that be the reason later versions are so much slower and more buggy than my trusty CS4?
    (Point in fact.
    In CS4 and earlier on the Mac, all plugin resources are gathered into neat, small packages inside a single large indexed file. That makes sense, because every single plugin resource is just a couple of bytes long -- say, a single icon, or a single string "Menu Item Name". With CS5, the programmers suddenly took a Lazy Turn and wrote out every single resource as a single small file. That means that
    1. (Annoying!) Since hard disk space is allocated by the kilobyte (typically 4Kb chunks), 10 tiny resources totalling 1 Kb now will suddenly occupy 40 Kb of disk space. Sure, hard disk space is cheap. Apparently, it's even cheaper than doing some programming -- or even just using the load code from the last version!
    2. (Frustrating!) Locating, opening, loading, and then closing a single file takes time and resources, but after a file got loaded into memory, you can do with it whatever you want. Locating, opening, loading and then closing each of the dozens of small files per plugin takes lots of time. Is that the reason CS5.5 starts up so incredibly slow? Jongware sez: yeah for sure it won't help.
    /Point in fact).

  • How to apply multiple paragraph styles to one sentence?

    I'm using paragraph styles but is not helpful because I'm trying to apply 2 different styles within the same sentence which is not working.
    To make it work I select the sentence, apply the style, for instance "xfont-regular" then I select the word within the sentence that I want it to have a different style and I choose from the font list maybe italic so that it looks "something like this"
    Obviously by doing this, I'm loosing all the benefits of using p styles and of course it's so time consuming. Is there any way to break the sentence, keeping it in the same line, so that I can apply different styles to it? and still keep the benefits of just going to the styles and make the changes to the whole document that have that style applied.
    Thank you

    pchinique wrote:
    I'm using paragraph styles but is not helpful because I'm trying to apply 2 different styles within the same sentence which is not working.
    To make it work I select the sentence, apply the style, for instance "xfont-regular" then I select the word within the sentence that I want it to have a different style and I choose from the font list maybe italic so that it looks "something like this"
    Obviously by doing this, I'm loosing all the benefits of using p styles and of course it's so time consuming. Is there any way to break the sentence, keeping it in the same line, so that I can apply different styles to it? and still keep the benefits of just going to the styles and make the changes to the whole document that have that style applied.
    Thank you
    As Diane King mentioned, nested character styles may work for your need. Her example was an initial dropped capital (multi-line first one or several letters of a paragraph.) Dropped caps are a specific type of nested style - always the first one or more characters in a paragraph, two or more lines high.
    To use the general kind of nested style, you need to be able to identify the word or words within the paragraph that gets the nested character style. For example, the third word, or the first two words after the first semi-colon. If there is no pattern of word(s) that can be identified by position or sequence, it's possible that a GREP style can be used to find a common pattern of characters and apply a character style to it, for example a telephone number, date, or currency amount that's identified by a dollar sign, pound, or yuan.
    Search InDesign Help and Google for "InDesign nested style," "InDesign grep style," and similar terms (without quotes) for details. There have been many discussions of GREP on this forum.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

Maybe you are looking for

  • Terrible Flickering/Delay While Playing Video in Hyper-V

    Hello Community, I have a Hyper-V server running on Windows 8.1. I have had it for a couple years now. There's been this problem that has been bugging me (I can't believe I waited this long to say anything!) and I wanted to see if someone can help me

  • Should i need a new oracle instance or schema?

    Hello All, I know that this is may sound like a silly question but i really need to know. In our company we have a server with oracle standard and a instance that holds a financial database. Now, the company bought a new antivirus software and it run

  • How to lock a folder using admin password??

    hello, i want to lock a folder with admin user name and password, and, i dont want to use Utilities->Disk Utility then Select File->New...->Blank Disk Image. Can we lock a folder without creating an image??? plz help!!! i have mountain lion, 27inch i

  • Show data from sql server to oracle db

    Hi, I am using oracle 10g R1 on windows 2003 platform. On one machine database 10gR1 is running and on other machine sql server is running. I want to retrieve some data from sql server to oracle database. Please tell me how I can show data from sql s

  • AttachMovie adds library item twice?

    Hi everyone! I've come across this problem for the second time now, and I'm still not sure what solved it the first time. I have a timeline that contains the clip "contentMC". On the same timeline the following AS appears: _root.contentMC.attachMovie