[CS4 JS] Find a paragraph style and get text contents

Hello,
I would like to get to contents of text that is applied with a specific paragraph style, so that I can copy it to another text frame
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedParagraphStyle = "headline";
// and then get the value/contents of that applied paragraph style
Sjoerd

Something like this:
str = "";
found = app.activeDocument.findText();
for (i = 0; i < found.length; i++)
   str += found[i].contents;
"str" now contains aal text styled with that paragraph, which you can now save in a text file.
Peter

Similar Messages

  • How to get all paragraphs style and their fonts of a  indesign file and write all info with para info into txt file with scripting

    how to get all how to get all paragraphs style and their fonts of a  indesign file and write all info with para info into txt file with scriptingstyle and their fonts of a  indesign file and write all info with para info into txt file with scripting

    I write the script this one works
              var par=doc.stories.everyItem().paragraphs.everyItem().getElements();
      for(var i=par.length-1;i>=0;i--)
           var font=par[i].appliedParagraphStyle.name;
            var font1=par[i].appliedFont.name;
             var size=par[i].pointSize;
            WriteToFile (par[i].contents  +   "\r" +  "Style  : " + font  + "\r" +  "FONT1  : " + font1  + "\r" +  "Size  : " + size  + "\r", reportFilePath);
                            function WriteToFile(text, reportFilePath) { 
        file = new File(reportFilePath); 
        file.encoding = "UTF-8"; 
        if (file.exists) { 
            file.open("e"); 
            file.seek(0, 2); 
        else { 
            file.open("w"); 
          file.writeln(text);  
        file.close(); 
    Thanks for all your support

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • [CS4/5] [JS] Which paragraph style does the panel context menu action work on?

    Hi all,
    I am trying to write something similar as http://forums.adobe.com/message/2866720#2866720 for the paragraph style context menu. I also would like to find out which paragraph style has been selected when the context menu opens. In the thread there is a "dirty" solution for this, the Edit and Apply options of the context menu also mention the name of the paragraph style. This works as long as the paragraph style is unique.
    In my situation the paragraph style names are not always unique, the same name is used in different paragraph style groups. I thought of an even "dirtier" solution that might work for this. The basic idea behind this is to create a new text, asfaik Indesign will automatically apply the active paragraph style to this text and it is easy to grab this style. The code for this is below:
    var myDoc = app.activeDocument;
    var myTextFrame = myDoc.textFrames.add();
    myTextFrame.contents = "grab the paraStyle";
    var myParaStyle = myTextFrame.paragraphs[0].appliedParagraphStyle;
    myTextFrame.remove();
    In my situation this approach seems to work fine but I am wondering if there is something against creating a new textframe and removing it later? And will the new text always get the current selected paragraph style?
    Best Regards,
    Bill

    I finetuned the snippet above a bit further. In some cases the context menu will be activated (right mouseclick) from a style that is not currently selected. In thoses cases the example above doesn't give the correct information. In order to avoid this I am now applying the paragraph style of the current context menu to an intermediate textframe. The snippet below is placed inside the EventHandler of my custom context menu item.
    var myDoc = app.activeDocument;
    //store current selection
    var mySelection = myDoc.selection;
    //create intermediate textframe
    var myTextFrame = myDoc.textFrames.add();
    myTextFrame.contents = "grab the paraStyle";
    myTextFrame.select();
    //apply the para style of the context menu to the intermediate text
    var contextMenu = app.menus.item("Text Style List Context Menu"); //or "$ID/RtMenuStyleListItem"
    var applyMenuItem = contextMenu.menuItems.itemByID(8488).associatedMenuAction; //Apply "para style for context menu"
    applyMenuItem.invoke();
    //grab the para style of the context menu
    var myParaStyle = myTextFrame.paragraphs[0].appliedParagraphStyle;
    //restore original selection and remove intermediate textframe
    myDoc.selection = mySelection;
    myTextFrame.remove();
    Again this snippet seems to work fine. I realize this approach will only work for para styles in a Document object and not for default para styles defined in the Application (suggestions to solve this?). A further refinement could be to first check if a para style name is unique, if that is the case the solution of Jongware (see http://forums.adobe.com/message/2861568#2861568) can be used and an intermediate textframe is not required.  
    I know this is a dirty solution but are there any issues with this approach?

  • Different paragraph styles within a text thread

    Does anybody know if it's possible to apply a different paragraph style to each text box in a text thread? I have three boxes: the first and the last have a small font and I'd like the middle one to have a larger font size.
    If it's not possible, is there an alternative way to do this?
    Thanks,
    Nacho

    Offhand i'd say that what Nacho wants to do will entail having separate text boxes...
    Seems to me that what he's doing is having the text flow from one box to another (column?). Obviously, changing / editing content will cause the text to shift its position.
    Nacho, i think you'll have to do one of the following:
    1/ Manually adjust the font style for the box you want each time you mke a correction
    or
    2/ Set up different, independent boxes (text areas) and style the box the way you want. Obviously changing text will mean changes in the area used by that box...
    Maybe someone else here can help out with a better suggestion...

  • HT201365 Downloaded iOS7 on my 4S. Mostly went well, but sometimes screens lock up (especially text, but also Settings). Find I cannot access and send texts sometimes, plus do not receive some texts from others (group messages real problem).

    Downloaded iOS7 on my 4S. Mostly went well, but sometimes screens lock up (especially text, but also Settings). Find I cannot access and send texts sometimes, plus do not receive some texts from others (group messages real problem). Any work around? And related problem: Getting told can not connect to network when trying to sign on with Apple ID to launch Facetime and Messages.

    I've restarted several times. If I restore from backup, unfortunately the backup was done after iOS7 downloaded. Now, am I wrong that "restore as new" will essentially wipe me out? If so, and having backup, you're saying essentially start over and then backup?

  • Read Outlook Email and Get Specific Content from Mail with PowerShell

    Hi Everyone,
    I would like to get full content value by searching in mail body with PowerShell but I stuck at one place in scripting and would required help from your side. Below is my script with description.
    #Connecting Outlook with below command
    $Outlook = New-Object -ComObject Outlook.Application
    # Now getting all folders info in variable (Shows Email, Calendar, Tasks etc)
    $OutlookFolders = $Outlook.Session.Folders.Item(1).Folders
    #Now connecting Inbox mails
    $OutlookInbox = $Outlook.session.GetDefaultFolder(6)
    #Now reading latest mail
    $latestmail=$OutlookInbox.items | select -last 1
    #Now calling email content and getting email content as output in html
    $latestmail.HTMLBody
    #below is output
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
    <HTML>
    <HEAD>
    <META NAME="Generator" CONTENT="MS Exchange Server version 14.00.0004.000">
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <!-- Converted from text/plain format -->
    <P><FONT SIZE=2><A HREF="https://test.abc.com/sys/servlet/ViewFormServlet?f
    orm=NTE%3aNotifier&server=sm.user&eid=NTS000299462947">https://test.abc.com/sys/servlet/ViewFormServlet?form=NTE%3aNotifier&server=sm.user&eid=NTS4556555
    294437</A><BR>
    <BR>
    Incident IND000008655308 has been assigned to your group 'Windows
    ADMINISTRATION'.<BR>
    Company: ABC<BR>
    Customer Name: XYZ<BR>
    Service Type: Infrastructure Event<BR>
    Priority: High<BR>
    SLA Resolve Target Status: Within the Service Target<BR>
    SLA Response Target Status:<BR>
    Reported Source: Systems Management<BR>
    *******************************************************************<BR>
    Summary: server1.abc.com: Average (5 samples) total cpu is now 100.0
    0%, which is above the error t<BR>
    <BR>
    *******************************************************************<BR>
    Notes: server1.abc.com: Average (5 samples) total cpu is now 100.00%
    , which is above the error threshold (100%)</FONT></P>
    </BODY>
    </HTML>
    # Now my target is to search incident number which is starting from IND* and server name (server1.abc.com). I tried below code but not getting value. Please help me to get these two values from email.
    $latestmail.HTMLBody -match "IND"
    #Output
    True
    #but not getting full that is IND000008655308.
    Please help me.

    Try this:
    if($latestmail.HTMLBody -match 'IND(?<x>\d+)\S'){
    $value='IND'+$matches['x']
    }else{
    Write-Host 'Not found'
    \_(ツ)_/

  • My daughter and granddaughter both have the same model iPhone.  I can text my granddaughter but when I try to text my daughter I get the message that she is not registered at iMessage, but I know that she is and gets texts all the time. What do I need to

    My daughter and granddaughter have the same model iPhone.  I can go messages and text my granddaughters phone from my ipad2, but when I try to text my daughter I get the message that she is not registered with I message, but she is registered and gets texts all the time.  What do we need to do?

    Pattypegr wrote:
    The blue bubble will not turn on on the iPad when I try to message her on her I phone.  She has IMessage turned on.
    What blue bubble are you trying to turn on? If you mean that the Send button will not work, go to Settings>Messages>Show Subject Field>Off. Make sure that is set to off.
    If you send an iMessage, the texts between the devices appear in a blue bubble.
    iMessages only work between iOS devices and they are different than the standard text messages that any cell phone can send to another cell phone.

  • [win][js][cs4]find/change paragraph styles without losing local overrides

    Hi guys i need a little help here.
    I created a javascript which will find and replace doc file paragraph styles with indesign paragraph styles. everything works fine but the problem is that when it applies the paragraph styles it loses all local overrides. i tried:
    changetext(false);
    but its not working is there some kind of conditional parameter that i can put in the changetext() function so that it wont clear local overrides?
    Thanks.
    CharlesD

    Thanks Kasyan. You're always there to save my day. Thank you very much...
    I slightly modify the script to go through all my paragraph styles that need to be replaced coz there are hundreds of them. Im not sure though if this is the best or is there any faster way to do this:
    replace("T1", "Text", "T1");
    replace("T", "Text", "T");
    replace("1", "Heads", "1");
    replace("2", "Heads", "2");
    function replace(input, folder, output) {
        var foundItem;   
        var doc = app.activeDocument;
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.findWhat = ".+";
        app.findGrepPreferences.appliedParagraphStyle = input;
        var foundItems = doc.findGrep();
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyleGroups.item(folder).paragraphStyles.item( output), false);
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

  • 'Clear Paragraph Style' and 'Clear Selection Style'

    In an old archived topic, someone wrote:
    quote:
    In DWMX, you could select text in the design view and in the
    "HTML Styles" window (which no longer exists in MX 2004) all you
    had to do was click "Clear Selection Style" and all HTML formatting
    (paragraph tags, font faces, colours, bold, italics etc) would be
    removed. This was marvellous for reformatting <font> tag
    based text with CSS. MX 2004 claims to be a CSS machine, but it
    seems to lack this very important feature which helps to re-inforce
    the use of CSS over font tags.
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=189&threadid=714513&arc tab=arc
    I absolutely agree, and none of the alternative methods
    people suggested in that thread matched this lost feature for speed
    and ease of use.
    I've not seen a replacement for these commands in Dreamweaver
    8 either (although I've often wished for one). Does anyone know of
    a hidden feature that exists in version 8 for removing all the HTML
    formatting in one fell swoop?

    I count 4 steps.
    1. Copy the entire line
    2. Paste into notepad
    3. Copy the entire line
    4. Paste into DW
    That does it nicely no matter how much presentational markup
    there is.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Kals" <[email protected]> wrote in message
    news:[email protected]...
    >
    quote:
    I think what the O/P is wanting is a quick and easy method to
    remove
    > all of
    > those presentational tags.
    >
    > Thanks Gary ? spot on! I'll use the term 'presentational
    markup' rather
    > than
    > 'HTML styles' from now on. (Excuse my ignorance, but
    what's an 'OP'?
    > Should I
    > like being called such a thing? :)
    >
    >
    quote:
    Murray: ? but you just cannot create predefined "HTML STYLES"
    any
    > longer.
    > It's no great loss....
    >
    > Agreed! Okay, we've established that no one's lamenting
    the loss of 'HTML
    > styles' in the sense of a style sheet that stores HTML
    presentational
    > markup.
    >
    >
    quote:
    And if "HTML STYLES" were not used in the first place, then
    even having
    > that feature available now wouldn't help OP, if your
    interpretation is
    > correct.
    >
    > Perhaps you are misinterpreting what those commands did.
    'Clear Paragraph
    > Style' was the equivalent of applying a predefined 'HTML
    style' with no
    > presentational markup ? making it as far as I know, the
    quickest, easiest
    > way
    > to strip all presentational markup out of your HTML
    (irrespective of
    > whether
    > the markup originated through the use of 'HTML styles').
    This could have
    > very
    > easily been replaced by a stand-alone command.
    >
    >
    quote:
    There are certainly quick and easy ways to remove many of
    them.
    > Okay then, here's the test. How many steps does it take
    you to clean up
    > the
    > following paragraph?
    >
    > <p align="center"><font size="+1" face="Times
    New Roman, Times, serif">The
    > quick
    brown fox
    jumps over the
    <font
    > color="#FF0000">lazy</font>
    dog</font></p>
    >
    > I count 10 steps if you select the entire paragraph and
    use nothing but
    > the
    > Properties panel and/or Text menu. Perhaps you can beat
    my attempt. If I
    > use
    > the 'Clean Up HTML' command, it takes me about 20
    seconds to check for and
    > type
    > in all the individual tags I want removed, then I still
    have to manually
    > fix
    > the alignment. Do you know of a quicker, easier way?
    >

  • Issue with paragraph styles and overflow

    Hi all, I have been having a massive problem with my paragraph styles for a book I am working on for my employer.
    http://cl.ly/2b3p2q412H0b1r3n1L3Z
    The paragraph on the bottom right is the overflow text. For some reason, although the paragraph is all in the "body" paragraph style, once it goes into the overflow textbox, the spacing changes. If I expand the textbox on the left, everything is single spaced. It is quite bizzare.
    I have also tried deleting the textbox on the right and creating a new overflow textbox, but there is no change... I can't figure out what is happening.
    I am using Adobe InDesign CS5.5..
    Thanks!

    (Without looking at the file) Check that paragraph for "Align to baseline" settings.
    See http://www.youtube.com/watch?v=Jla1sy_0FLQ for what this is :)

  • I had an old iPod nano with my files saved on it and was stolen. I cannot find my old account. I bought an iTouch and made the new account that was needed for it to function. I was wondering how i could find my old account and get all the content back.

    I had an old iPod nano with my content saved on it and was stolen. As well, I can't find and access my old account that I had with it. I bought an iPod touch and made a new account so that I could use the iTouch. Anyone know how to find the old account and how to transfer data from the old one to the new account?

    This may help you find your iTune account:
    Frequently Asked Questions About Apple ID
    Without knowing your old account info there is nothing you can do.

  • How to handle paragraph styles in imported text with no tagged paragraph styles

    Hi
    Im currently trying to import a file (word file / excel I have both formats) into an indesign book and formatting the text automatically!
    My question is: How is it possible to reflow text into frames and when changing frame it changes paragraph?
    Or how is it possible to change paragraph style when forcing a line break when using text reflow?
    I have already figured out how to reflow the text, and actually also managed to relow text into the frames and change paragraph style. I know how to use the keep option, and by this change the paragraph style when e.g. changing frame break/page break etc.  (but if the content being flowed-in is not tagged with style names then I cannot figure out how to do it) The document and its content I whish to import do not have any tagged paragraphs!
    Then I tried to look into "object styles" and format a text frame on a master page with an object style, and by using a "dilimiter character" forcing the text to start in a new frame when bringing the frame into live on a page. But here I cannot make the "text frame/object style" to apply or to work.
    If any of you have a hint, I would be more than happy to hear from you
    This picture are illustrating the outcome I would to get to....

    If the incoming text does not have styles, or has only one style, there is really not much you can do other than assign styles after the import. If there are recognizable patterns in the formatting, a lot of that can be done with Find/Change, and there are a few scripts floating around that can help automate some of that.
    Also, if your styles have a a good "next style" heirarchy built in, you can select large blocks of text (up to the point where applying next style would be incorrect), then right click the style name in the paragraph styles panel and choose apply style and next style (remove overrides). Warning. Removing overrides will remove any locally applied formatting like bold or italics, so local formatting should be converted to character styles first. Applied character styles are not overrides and will be preserved.

  • Creating a new paragraph style based on text in a document

    I'm working on some scripts for a new ad our company is working on. They are wanting to have the ability to change the font weekly in the ads. However, they want the style sheets to change based on this. What I am having to do is write a script that gets the properties of the different paragraphs in the selected text frame, and make paragraph styles. Is there a way to get the properties of paragraph 1, and use that information to make a new paragraph style? Here is what I have so far;
    set charaStyle to get properties of character charaSelect of paragraph paraOne of myBox
    set makeStyle to make character style with properties {name:"MF Price" & charaSelect, based on:properties of character charaSelect}
    We are using InDesign CS 3. Thank you in advance for the help.

    this way - build ParaStyle definition from selected text - works only in UI
    in scripting you need to write your own procedure - read all params and set them one-by-one in ParaStyle definition
    robin
    www.adobescripts.com

  • Applying paragraph styles to placed text

    I have a catalog document built  with with master pages and paragraph styles. The layout has a grid of  image boxes for product with a text box beneath for descriptions. The  text boxes should have style 1 applied to the 1st line, and style 2  applied to the following lines. Style 1 is applied to the text boxes in  the master, and has next style set to style 2 in the paragraph style  settings. This works fine when typing directly in the document, but I am  placing the text from a word document. When I place the text, InDesign  is just applying the default text settings instead of the correct  styles. Is there a way to get it to automatially apply the correct  styles, or will I need to manually set the styles?
    Using CS5
    thanks,
    Katie

    Part of your answer is very easy: after you've placed your text, select a few paragraphs, and then right-click on "style 1" and select "Apply Style, Then Next Style." That's how to use "Next Style" on text that you've placed.
    The other part of your question -
    When I place the text, InDesign  is just applying the default text settings instead of the correct  styles. Is there a way to get it to automatially apply the correct  styles, or will I need to manually set the styles?
    is a fair bit more complicated. If you're placing Word files, and all of the text in Word is styled with "Normal," then you'd probably need to manually set styles. If the text is in Word, but is styled carefully, then you can click the "Import Options" checkbox upon placing, and you can do all kinds of things to the file, including stripping all Word formatting & mapping Word styles to InDesign styles. If you have text in some other format, it may be possible to automate styling, but it depends completely on what you have to place. Raw text with XML tags? CSV files? RTFs generated by a translation memory tool? If you can post example files or screenshots, we may be able to figure out a way to smooth out this part of your workflow, depending on the materials with which you're working.

Maybe you are looking for

  • Connect Mac mini and iMac... please!

    Connect iMac and Mac mini... please Posted: Jan 30, 2006 7:17 AM Reply Email Hi guys I can't figure out how to make my iMac and Mac mini talk to each other... let me explain better... I have a wired Linksys router that always worked ok connecting the

  • Can't publish - help!

    Hi everyone, I can't publish. I have a variety of backups of my Domain file, including some from months ago. These backups of my Domain all used to publish fine, but now I can't get any of them to publish. Currently I am trying to publish to a local

  • Would help to have a way to tell if addons will be compatible BEFORE I install an update. Lightning is the major concern for us.

    Thunderbird asks to update to 24.5.0 but I need to know for sure that Lightning has a compatible version before I do the update. Can't afford to lose that calendar. When I go look at the mozilla site for lightning it shows the current version, the on

  • Bizarre behavior @Id and @OneToOne annotation.

    Hi. In the code example below, if you move the @Id from the SKU attribute to the getSKU() method you would get an exception (see below for the stack trace): Exception Description: Entity class [class oracle.toplink.jpa.example.inventory.model.Item] h

  • Mac CS4 OnLocation codec missing?

    We have terabytes of data captured from onLocation CS3 in DVCPro100/HD (PC of course) and have edited on PC Adobe CS3, using the codec that came with onLocation CS3 install. We recently bought a new Mac with CS4, and it cannot read the Avi files onLo