Extract paragraph style name with formating

All
kindly help me How to extract ParagraphStyle name with formating to Sample.txt:
EG:
Style Name: "Body"
Font = "15"
leading = '"18"
Aligh = "Left"
etc...
Regards
Hurix
Edit by Dave Saunders: Something is preventing the Reply button from working. I'm hoping this edit will reactivate it.

Hi all,
This is something I threw together
doc = app.activeDocument,
ps = doc.paragraphStyles.everyItem().getElements().slice(0),
l = ps.length,
paraStyles = [],
c = 0;
while (l--) {
    var styleDetails = [], n = 0, s, x, p, q;
    s = ps[l].properties;
    for (x in s) {
        p = (s[x] && s[x].hasOwnProperty ("name")) ? s[x].name : s[x]; // change according to requirements.
        if (p && p.constructor.name == "String") p = '"' + p +'"'; // ok if the sctring doesn't contain a " mark
        else if (x == "tabList") p = getTabList (s[x]);
        else if (p instanceof Object && p.constructor.name != "Enumerator") {
            var objProps = [], z = 0;
            for (q in p) objProps[z++] = q + ": " + p[q]
            p = x + " {" + objProps.join(", ") + "}";
        styleDetails[n++] = x + ": " + p;
    paraStyles[c++] = "{" + styleDetails.join(", ") + "}";
temp = new File (Folder (Folder.temp) + "/" + doc.name + " Paragraph Style Properties  " + ("" + new Date).replace(/:/g,"\xB7").replace(/\s\S+$/,"")+ ".txt");
temp.encoding = "UTF-8";
temp.lineFeed = ($.os[0]=="M") ? "Macintosh" :" Windows";
temp.open('w');
temp.write("\uFEFF" + paraStyles.join("\r"));
temp.close();
$.sleep(300);
temp.execute(true);
function getTabList (t) {
    var tl = t.length, n, pTabList = [];
    for (n = 0; n < tl; n++) { // if the leader etc. contains a " then you have to use ' instead of "
        pTabList[n] = "({alignment: " + t[n].alignment + ', alignmentCharacter: "' + t[n].alignmentCharacter + '", leader: "' +t[n].leader +  '", position: ' + t[n].position + "})";
    return "[" + pTabList.join(", ") + "]";
function getGrepList (g) { // nestedGrepStyles
    return // couldn't be bothered to do this one, sorry
    var tl = g.length, n, pnestedGrepList = [];
    for (n = 0; n < tl; n++) { // if the leader etc. contains a " then you have to use ' instead of "
        // pTabList[n] = figure for yourself
    return "[" + pTabList.join(", ") + "]";
You can then recreate the styles by splitting the string by "\r" and using doScript or Eval.
Might be better to produce a tagged doc with <alignment> foo </alignment> type structure to get around quotation porblems
However for a simple import export snippet wouldn't this be better?
var doc = app.activeDocument,
      newDoc = app.documents.add(),
      fp;
// if you need to add function to remove app.styles that are automatically added to the new document
fp = new File (Folder.temp + "/" + +new Date + ".indd")
doc.saveACopy (fp);
$.sleep (500);
newDoc.importStyles (ImportFormat.TEXT_STYLES_FORMAT, fp); // can add all sorts of things to import or load
fp.remove();
// You now have a clean new Document to load the styles from using importStyles
Trevor

Similar Messages

  • How to export RTF with paragraph style names?

    Anybody can help me "how to export RTF with paragraph style names?"
    Thank you

    It's not something that's natively done with Indesign.
    However it's possible that it might be able to be scripted.
    Check the scripting forum
    http://forums.adobe.com/community/indesign/indesign_scripting

  • 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);

  • [Basic Paragraph] style name change to NormalParagraphStyle?

    i m trying to edit existing paragraph style. i was do it through kEditTextStyleCmdBoss. My problem is : As the command is process the name of [Basic Paragraph] style is changed to NormalParagraphStyle and it is now editable. How i can make its name field again not changable(i.e. preserve its original property)?
    Regards
    Kannu

    Hi,
    Have you some solution?
    Best regards:
    Karoly

  • Changing Paragraph Style Names

    I asked this question about a month ago, but I did't really ask it right.
    I am bringing documents from InDesign to InDesign6. In the process, we are changing style names to make things future compabile by eleminating all spaces. periods, dashes, etc.
    So, for example, Heading 1 becomes Heading_1, while Page No. - Left becomes PageNo_Left, etc. Easy enough to do for one or two documents by hand, but I have literally hunders of documents that are going to need this.
    So, I'm looking to write a script to more or less automate this process. I think I need something like:
         app.documents[0].paragraphStyle.item("Heading 1").name = "Heading_1"
         app.documents[0].paragraphStyle.item(Page No. - Left).name = "PageNo_Left"
         etc.
    Am I headed in the right direction? Any advice would be greatly appreciated.

    Figured it out. Script is:
    app.activeDocument.paragraphStyles.item("Heading 1").name = "Heading_1"
    app.activeDocument.paragraphStyles.item("Page No. - Left").name = "PageNo_Left"

  • Need SRM BW Vendor Evaluation Report Names with format

    It would be really appreciable if someone can share the SRM BW Vendor Evaluation Report Names along with the format.
    Cheers,
    Sheetika

    Hi Sheeetika,
    please check here..
    http://help.sap.com/saphelp_nw70/helpdata/en/42/de4c7e2f842cede10000000a1553f7/content.htm
    hope this will help you.
    Thanks,
    vijay.

  • Extract the File Name with extension on double clicking it

    Hi All,
    I have created on program in java and also created its exe file.
    The application store all the files you have selected in one directory, zip the folder and give the desired extension.
    example myApplication.fgc
    Now. I need to create an application which on double clicking the myApplication.fgc create the folder myApplication and store all the files i have selected.
    Please help me in this.
    Thanks in advance.

    I think you are talking about unzipping or extracting the contents
    of the Zip file. Use the API in 'java.util.zip'
    For code refer to
    http://www.javaalmanac.com
    There you would find the code!!
    Good luck!!

  • Written with a specific paragraph style Can I transfer data

    In a document in every text frame there are short texts written in paragraph style
    the data in this paragraph style can I transfer into a new text frame
    I'm doing this process with TOC
    Is it possible with a script
    If possible specified in the data (1. and 7.) can we transfer the characters with grep

    app.findGrepPreferences = app.changeGrepPreferences = null;   
    app.findGrepPreferences.findWhat = ".+";   
    app.findGrepPreferences.appliedParagraphStyle = "test"; //mention your paragraph style name 
    var mySearch = app.activeDocument.findGrep();   
    myFrame = myDoc.textFrames.add ({geometricBounds:[".5in",".5in","5.5in","5.5in"]});//textframe will created in the first page of your InDesign document 
    myFrame.insertionPoints[-1].contents = "CONTENTS\r"; 
    for(i=0; i<mySearch.length; i++)   
        var mySearchContent = mySearch[i].contents; 
        mySearchContent = mySearchContent.replace(/(\d+)(\t.+?\t)(.+?)(\t\d+)/g, '$1-$3'); 
        myFrame.insertionPoints[-1].contents = mySearchContent + "~f" // THİS ERROR  1-A~f2-A~f3-A....
    app.findGrepPreferences = app.changeGrepPreferences = null;

  • How to find text or paragraph by giving style name?

    Hello,
    can any body tell me,How to find text or paragraph by giving style name?actully i have so many styles which is applied on document.
    i want to find text in the document which have particular style name.is any method to find text by giving name of style?

    Any of the various findText methods, plus your paragraph style name in FindTextPreferences: http://jongware.mit.edu/idcs5js/pc_FindTextPreference.html
    Use Google to locate exact samples, as this has been done countless times before.

  • GREP for changing paragraph style?

    Okay folks, I have another one for all you smart people out there. I think GREP can be used to change formatting in the following instance, but I have no idea how to set it up.
    I have a very long document, essentially a phone book-type listing of names, phone numbers, addresses, well over 150 pages' worth. The paragraph styles are fairly simple, only two per listing. The name/phone number is bold with a right hand tab with leader dots to a phone number that is flush to the right side of the column. The following lines are flush left, not bold, but indented 6pts. I've placed the text file and assigned the entire thing the NameListing paragraph style. I'd like to use GREP to find the address lines and change them to the NameListingAddress paragraph style.
    Here's a screen shot to give you an idea. The left column is formatted correctly with both styles, the right column is "raw", all paragraphs formatted with the NameListing paragraph style.
    Is this an appropriate application for GREP? If so, how do I set it up to only change the paragraphs that "don't have tabs"? It would save me a crapload of time.
    THANKS again! --Dina

    If your intent here is to use the character style to trigger a variable, as I belive it is based on your other thread, you MUST apply the character style up to the first tab to pick up the text at the start of the paragraph. There are two approaches to automating the formatting after that, but it may be too late for you to be much help.
    In cases where every listing has the same number of lines it makes sense to use a unique paragraph style name (not necessarily format -- base on on another) for each lline and make it its own paragraph. Set up "next styles" to rotate through the list so each line is assigned the correct style based on the style of its predecessor. You get the rotation to sart over by making the first line style the next style for the last line. This works for manual entry and can be applied to an entire block of placed text in a single operation by selecting the text, then right-clicking the name of the first style to be applied and choose Apply <stylename>, Then Next Style.This ONLY works if you have exactly the same number of paragraphs in each listing.
    The other option is to use forced line breaks instread of paragraphs and use one style for the entire listing. Set a left indent and negative first line indent, create a character style for the part of the first line that you want to appear in your header and apply it Up To ^t^n (that's a little-known trick -- if you enter more than one character in the trigger for a nested style it will activate on the first instance of any of the characters listed that occurs, so for example if you enter the word cat, your style will end on the first, c, a or t that appears inthe paragraph. ^t is the metacharacter for tab, and ^n is for forced line break) so that the style will end at either the tab, if present, or the forced line break if there is no tab (if you use a right-indent tab instead of a regualr right aligned tab [tricky to do a leader, but that's another discussion] substitute ^y for the ^t), then add a nested Line Style for one line. That line style should use a second character style that is based on the first character style you created for the name text and has no other attributes if you want the line to be the same from end to end. Sounds more complex than it is, and will work for listings with variable lenghths. The trick is to repalce your paragraph returns with forced line breaks, and will require a little thinking.
    If using separate paragraph styles for each line, you'd use the same technique of a nested style up to a tab for the first line, but there is no need to get fancier since it will apply to the whole line if there is no tab. The paragraph style, in this case, would carry all of the bold and size formatting (and no need for any indents), and the character style would be nothing more than a name that will allow you to use it in the variable.

  • Two more options in the paragraph styles panel

    I would like two options in the paragraph styles panel.
    1.
    The posibility to set the 'Sort by name' option as a default or persistent
    2.
    The ability to label the styles with colors

    Let me second the motion for a persistent "Sort by name" option for the Paragraph Styles panel.
    In addition, somebody at Abobe "improved" the Paragraph style "Basic Character Formats" menu for CS6 by sabotaging the natural progression of tabbing directly from setting the *Font Size* to setting the *Leading* amount. Why would anyone at Adobe think that going from *font size* to *kerning* is an improvement for design professionals?

  • Scipt to Rename Paragraph Styles on Several Files

    Hi all!
    I am a newbie here. First at all I wanted to thank you soooo much for sharing all your knowledge with others, thanks!
    Now here my question: I need to change the name of a bunch of Indesign files (they all have the same Paragraph style names).
    Can it based on following script (thanks Vamitul and Jongware for this script)? If so what should be changed?
    Thank you.
    var doc=app.activeDocument;
    var myPstyles=doc.allParagraphStyles, l=myPstyles.length;
    while (l--){
    try{
    myPstyles[l].name=myPstyles[l].name.replace("Old Style","New Style");
    }catch(e){}
    alert ("Done!\nYou can go outside and play now");

    WashingCatz wrote:
    Thanks, Yogi, the problem isn't getting styles loaded into a new doc (we already carry the styles in the INDD template everyone uses). I was trying to generate a tip sheet that Word or Excel users could use to prep their files with the right fonts and so on before sending documents to us for placing in INDD, without having to pull up every style and type it out manually.
    I'll try the download suggested above by Peter (but I bet downloading and installing it on my PC gives our IT department fits!).
    thanks!
    Exporting from ID to RTF preserves the appearance and also the style names of text.
    Importing the RTF into Word should retain the appearance and style names - it does in NeoOffice. However, whatever format properties that Word doesn't recognize won't be present when you place the Word file into ID. If you place the Word file into a new blank ID document, the style names will be preserved, but some properties will be missing.
    If you place the Word RTF into an ID document that has the original style names and property definitions, select Show Import Options, so you can choose to retain the ID file's style definitions for all style names that match those coming in from the RTF file.
    I don't know if Excel recognizes the style names that are preserved in RTF that's imported or pasted into Excel documents, but it should retain the text format properties that it understands. If Excel doesn't retain style names, going from Excel to ID won't have style names that you can use to map to ID style names.
    HTH

  • Do paragraph style overrides work differently in CS3 vs CS4?

    Hi All-
    I’m in the process of moving a workflow from CS3 to CS4, and have run into an unexpected problem. In the existing CS3 workflow, we receive copyedited text with Word paragraph styles applied, then import this text into our InDesign template. This template has all the same paragraph style names as the Word file, so we tell InDesign to use the InDesign style definitions in the Import options. So, for instance, the Word style for Para_Text is Times New Roman 12pt, and the InDesign style for Para_Text is Helvetica Neue 8pt, and on Import InDesign automatically changes it to Helvetica Neue 8pt. This is as we want it.
    Things fall apart, however, when we import the same text into the same template in InDesign CS4. It still applies the InDesign style definition, but has additional overrides to make it look like the Word style definition. So, it recognizes that the underlying paragraph style should be Helvetica Neue 8pt, but it then preserves Times New Roman 12pt as an override. If I select the text and do Clear Overrides, it’ll revert to the Helvetica Neue 8pt we want it in, but for other reasons that solution is less than ideal.
    I think I can come up with a rather kludgy way around this, but I’m trying to understand exactly why we’re getting the different behavior in CS4. It seems like paragraph style conflicts are being handled in a different way in CS3 than CS4 – in CS3, if the InDesign paragraph style specifically spelled out a font, that would dominate on import; now, in CS4, it’s allowing the Word paragraph style to seep through as an override. Any thoughts as to why this is happening?
    Thanks,
    -Nate

    Hi Chris.
    Good news. I cant tell you how happy i am for all your help ;-) and you other guys.
    The latest Eizo 5.2.1 software fixed the problem on all 3 Eizo monitors.. Weeee
    I'm back to normal.
    Now i just have another damn problem started not long ago ;(
    My Photoshop CS3 and CS4 keeps crashing on me after a wile of work ???
    I tried everything. Deleted preffs etc. etc.
    It have been working for long long time but suddenly it keeps crashing all the time.
    I tried to remove some new plug-ins, but it was not that.
    Only thing i did also was to install new ram.
    Upgraded from 10GB to 14GB in all our Mac Pro.
    So after i tried to switch the ram around to check if some was bad.
    Also run some memory software but everything came out right.
    So now the only thing left is that Photoshop dosent like ram between 14GB & 16GB.
    Under was fine and i never tried over 16 gigs.. weird
    Any ide what could corse this ?

  • Why won't paragraph styles change?

    I opened a document from a few months ago and updated paragraph styles to a different font. However when I click on text and assign a style it has no effect. If I go to "basic paragraph" and click on that while holding down the option and shift keys, then it seems to remove whatever is stuck and then I can assign the style. But if I have to do this with every part of this 70 page document it is going to take a long time. Is there some way to make this go easier?
    The other thing is that I assigned keys to each style and I notice that even though I changed the paragraph styles to a different font the keys say they are assigned to the prior font, so maybe this is part of the problem.
    Suggestions very welcome.

    No.
    Break Link with Style does exactly what is reads.
    If you have a paragraph using the 'Body' style and you use the Break Link with Style option, then the paragraph retains the current appearance and settings, but is no longer associated with the 'Body' style. So, when and if you change the 'Body' style, that paragraph will not change.
    Clear Overrides reverts manual styling to the applied Paragraph Style. So, using the example above, assume your 'Body' style uses Myriad Pro Bold, and you manually change the font in a paragraph to Myriad Pro Black, that is an override. Selecting "Clear Overrides" reverts the font back to Myriad Pro Bold.
    Clear Overrides does not appear in the palette menu for character styles.
    Your text cursor needs to be active within the paragraph (or some of the text must be selected with the text tool) in order for the contextual menu to show the Clear Overrides option.
    Another option is to check the Paragraph Style Palette with the text cursor active in a paragraph. If there is any paragraph style applied, then it should appear bolded in the list. If there are any overrides applied, there should be a
    + at the end of the style name. You can then Control Click on the Paragraph style to see a list of options such as:
    Apply Style
    Apply Style, Clear Overrides
    Apply Style, Clear Character Styles
    Apply Style, Clear All
    HTH
    -mt

  • Reg.Apply paragraph style

    Hi All,
    Can you please anybody help me that how to apply the paragraph style which is available in Indesign with case insensitive in find/change grep options.
    I have tried with below code but the style applying only with case sensitive.
              myStyleName = myString.substring(1, myString.length-1);
                if(myDocument.paragraphStyles.item(myStyleName) == "[object ParagraphStyle]")
                    myStyle = myDocument.paragraphStyles.item(myStyleName);
                    myName = myStyle.name;
                    app.findChangeTextOptions.caseSensitive = false;
                    app.changeTextPreferences.appliedParagraphStyle = myStyle;
                    myDocument.changeText();
                    app.changeTextPreferences = NothingEnum.nothing;
                    app.changeTextPreferences.changeTo = "";
                    myDocument.changeText();
                    app.changeTextPreferences = NothingEnum.nothing;
    Please help me to figure out this issue.
    Thanks in advance.
    Regards,
    Sathya Rani M

    Hi Jarek,
    Thank you for your reply. Actually I need to find the style name with tag from activeDocument.
    For eq. if <lrh> or <LRH> found in activeDocument then find the "lrh" style available in Indesign and apply.
    Here is my full code. Please look into it.
    var myDocument = app.activeDocument;
    var myDocument = app.documents.item(0);
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findChangeTextOptions.caseSensitive = false;
    app.findGrepPreferences.findWhat = "(?i)^<\\s*\\w+\\s*>";
    var myFoundItems = myDocument.findGrep();
    if(myFoundItems.length != 0)
            var myFoundTags = new Array;
            for(var myCounter = 0; myCounter<myFoundItems.length; myCounter++)
                myFoundTags.push(myFoundItems[myCounter].contents);
            for(var i = 0; i < myFoundTags.length; i++)
                myString = myFoundTags[i];
                app.findTextPreferences.findWhat = myString;
                myStyleName = myString.substring(1, myString.length-1);
                if(myDocument.paragraphStyles.item(myStyleName) == "[object ParagraphStyle]")
                    myStyle = myDocument.paragraphStyles.item(myStyleName);
                    myName = myStyle.name;
                    app.findChangeTextOptions.caseSensitive = false;
                    app.findChangeTextOptions.includeFootnotes = false;
                    app.findChangeTextOptions.includeHiddenLayers = false;
                    app.findChangeTextOptions.includeLockedLayersForFind = false;
                    app.findChangeTextOptions.includeLockedStoriesForFind = false;
                    app.findChangeTextOptions.includeMasterPages = false;
                    app.findChangeTextOptions.wholeWord = false;
                    app.changeTextPreferences.appliedParagraphStyle = myStyle;
                    myDocument.changeText();
                    app.changeTextPreferences = NothingEnum.nothing;
                    app.changeTextPreferences.changeTo = "";
                    myDocument.changeText();
                    app.changeTextPreferences = NothingEnum.nothing;
    But it is applying style only if "lrh" is present. It should be find case insensitive. please help me out.
    Thank you.
    ~Sathya Rani M

Maybe you are looking for