InDesign crash while applying character style

Hi all,
A)I have problem with applying character style to selected text.
when character style is applied to selected text indesign get crashes.
my code snippet is as follow
input parameters
1.RangeData paraRange // start and end index of paragraph
2.storyUIDRef // uidref of current story
          code snippet
          // valid text model
          InterfacePtr<ITextModel> textModel(storyUIDRef, UseDefaultIID());
          if (!textModel)
   break;
          //wax strand
          InterfacePtr<IWaxStrand> waxStrand(((IWaxStrand*)textModel->QueryStrand(kFrameListBoss, IID_IWAXSTRAND)));
          if (waxStrand == nil)
   break;
          //WaxIterator
          K2::scoped_ptr<IWaxIterator> waxIterator(waxStrand->NewWaxIterator());
          if (waxIterator == nil)
    break;
          //first wax line of paragraph
          IWaxLine* waxLine = waxIterator->GetFirstWaxLine(paraRange.Start(nil));
          //iterate each waxline
          while (waxLine != nil && (waxLine->TextOrigin() < paraRange.End()))
    //Iterate for all runs
   K2::scoped_ptr<IWaxRunIterator> waxRunIter( waxLine->QueryWaxRunIterator() ) ;
   IWaxRun * waxRun = waxRunIter->GetFirstRun();
   while (waxRun)
   int32 startPos  = waxRun->TextOrigin();
   int32 endPos = startPos + waxRun->GetCharCount();
   RangeData textRange(startPos ,endPos);
   ISelectionManager* selMgr = m_activeContext->GetContextSelection();
   if(!selMgr)
    break;
   //get valid textselection suite
  InterfacePtr<ITextSelectionSuite> suite(selMgr, UseDefaultIID());
                              if (!suite)
   break;
                              //select  text
  suite->SetTextSelection(storyRef, textRange, Selection::kScrollIntoView, nil);
                              //created style from selection using  " SnpManipulate::TextStyleCreateStyleFromSelection" method.
my code get crashed at highlighted text( int32 startPos  = waxRun->TextOrigin();).
B)my next question is how to get textstyle ranges of a selected paragraph.
please help me.
Thanks
Tahir

A) Make sure that the all parcels of the text is composed before you iterate it, see ITextParcelListComposer. I don't quite understand what you are trying to achieve. You want to apply a character style to a range of text, but the code iterates wax lines and iterate the runs of each line  and sets the current selection to be the run on each iteration. Why not just:
InterfacePtr<ICommand> icmd(textmodelCmds->ApplyStyleCmd(index, length,styleUID,kCharAttrStrandBoss,kFalse));
B) Walk the kCharAttrStrands to the get information:
InterfacePtr<IStrand> strand((IStrand*)textmodel->QueryStrand(kCharAttrStrandBoss,IStrand::kDefaultIID));
then call stand->GetRunLength() a number of times until, you are through the selected part of the text / paragraph

Similar Messages

  • Applescript-Apply Character Style to Select Words in InDesign CC

    I'm trying to apply a character style to the first several words of a paragraph. The number of words varies, but it is essentially every word before a comma.
    Here's what I have so far:
    tell application "Adobe InDesign CC 2014"
      tell document 1
      tell page 2
      tell (item 1 of page items whose label is "HabitsContent")
      tell paragraph 2
      repeat with i from 1 to count of characters
      if contents of character i = "," then
      exit repeat
      end if
      end repeat
      set applied character style of characters 1 thru i to "Italic"
      end tell
      end tell
      end tell
      end tell
    end tell
    Viewing the log of the script, it finds the comma; however, the script ends up italicizing the entire paragraph. Any ideas?

    For anyone else who has a similar question, here's what works:
    tell application "Adobe InDesign CC 2014"
    tell paragraph 2 of (item 1 of page items whose label is "HabitsContent") of page 2 of document 1
    set a to paragraph 1 as list
    set a to text item 1 of a
    set old to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {","}
    set font style of characters 1 thru (count of text item 1 of a) to "Italic"
    set AppleScript's text item delimiters to old
    end tell
    end tell

  • Getting ALL applied Character Styles in a paragraph

    I'm trying to get all applied Character Styles of a paragraph in a InDesign CS2 Document.
    With myParagraph.appliedCharacterStyle I just get the first but not all applied Charcter Styles.
    Is there a possibility to get them?
    greets
    st

    If they're applied directly and not by nested style, then you should examine the appliedCharacterStyle of each TextStyleRange in the paragraph.
    If they're applied by nested style, you have to do a lot more work.
    Dave

  • InDesign crashes while trying to update InCopy stories.

    InDesign crashes while trying to update stories. I receive "serious error" message.

    Our main InCopy guru is away from the forum for a day or so, but maybe someone else (not me) has some ideas. It will help though to get some more basic info.
    What versions of ID, IC and your OS? Are the lates patches for ID and IC installed?

  • InDesign erroneously applies character style to imported text

    For a year, I had been importing text into InDesign with little trouble until this problem starting happening and I can't figure out why.
    Let's say I have a CS3 file with defined character and paragraph styles.
    If I draw an empty text box, InDesign shows the character style "superscript" and paragraph style "ext_all" are applied. I can select "Break Link to Style," but if I import text into that box, the "superscript" character style is applied.
    The following happens whether I create a text box first or not:
    If I import a styled Word file, all the text comes in styled "superscript" until it reaches a Word character style.
    If I import an InDesign Tagged Text file, all the text comes in styled "superscript" until it reaches a character tag.
    If I import a very simple one sentence rtf file, all the text is styled "superscript."
    Anyone run into this? I've tried googling, but can't find a discussion about it. Thanks in advance!

    Perhaps you've inadvertently set those styles as the defaults? That would happen if you click on them with nothing selected. For the current document switch to the text tool and make sure there is no cursor active or text frame selected, then check to see that the character style is set to [None] and the paragraph style to what you would like to be your default. Also check the settings in the character and paragraph panels.
    To make sure this doesn't carry forward into any more new documents, if indeed that was the problem, close all documents and repeat the above steps. With no documents open your selections will become the defaults for all new work until changed.
    Peter

  • InDesign CS4 crashing when applying object styles

    When i try to use IObjectStyleSuite->ApplyObjectStyle with the name of an object style that is inside a group, indesign Crashed.
    I've tried using the full name of the style path -> group:stylename but it doesn't work.
    Anyone faced this problem?
    Thanks in advance.

    As a last resort, when I run into the weird problems, I go through a process of elimination to find the offender.
    As example, I would delete half the images and try the update. if it works, I know the problem was in one of the images I deleted. If it doesnt, I'd delete the other half and try again. I keep cutting the number of images I remove in half till I'm down to whatever it was causing the problem. The I save it as a newfile type and re-import/place.
    Kind of a pain in the tookas, but it works when I'm really stumped.
    HTH
    -Ted

  • Finding MANUALLY applied character styles

    Hi all,
    We're in the process of switching to an XML workflow, and as one of our interim steps we're applying tags to paragraph and character styles in some of our documents. I'm aware of the option to map styles to tags and this should work well for paragraph styles. However, we're looking for a way to only map the character styles that have been manually applied.
    As an example, we have a paragraph style for instructions that has a bold number nested at the beginning of each paragraph. In other places, the same character style may be used to bold a specific word, but it is applied manually. Is it possible to map to tags ONLY the character styles that were applied manually? We do not want tags identifying character styles that were applied via Nested Styles or GREP Styles.
    I am assuming this would take some sort of script, which is why I'm posting in the scripting forum. Does anyone know if this is possible?
    Thanks in advance,
    Matthew

    Another InDesign oddity!
    If you fill a frame full of placeholder text and assign a "Bold" character style to, for example, a Nested Style:1 word, and a GREP style \<\w{4,6}\>, then use regular (or GREP) Find Text to search for the character style, it'll only highlight words that are at the start of the paragraph. Now that is wrong, wrong, wrong, because
    (a) it should not find any of them -- if you click your cursor into one of these bolded words, the Character Style panel says it's [None].
    or
    (b) it should find all of them, not just those that happen to be at the start of a paragraph. (BTW -- it's not the Nested Style it picks up; when using only GREP styles it'll also find words-at-the-start).
    It is funny, if things like this tickle you, that in a script "findText" works exactly the same. However: if you 'found' bold text and then interrogate what character style it has applied, it will only return your "bold" style if it was applied manually.
    See this script -- test with a placeholder text, aforementioned Nested/GREP styles, and a few hand-picked words that you applied "bold" to yourself. It will only report the ones you marked.
    app.findTextPreferences = null;
    app.findTextPreferences.appliedCharacterStyle = "bold";
    list = app.activeDocument.findText();
    r = [];
    while (list.length)
         next = list.pop();
         if (next.appliedCharacterStyle == app.activeDocument.characterStyles.item("bold"))
              r.push (next.contents);
    alert (r.join("\r"));

  • InDesign Crashes when Accessing Character Panel

    I just updated my Mac OS 10.6.7 with CS5 after uninstalling CS3, which functioned without any problems.  Now, after both creating new documents and opening previously created documents, InDesign is having all kinds of problems when I attempt to access the font list in the character panel.
    InDesign will crash everytime while I am scrolling through the font list.  I have tried using the Characer Panel window, as well as the font option at the top when using the text tool.  InDesign crashes either way.
    I have validated all of my fonts, removing those who were tagged as corrupt, uninstalled & reinstalled inDesign, and also removed my perferences folders to restore to default workspaces.  After all of that, InDesign continues to crash.
    Does anyone have any suggestions on what to do next?  I thought at first it was a corrupt font file, but now I'm not sure what it could be.

    There are some probems that do affect InDesign though.
    The one I've seen is fleeting.
    Open a document and set a substantial quantity of text (say, a full page) in Utopia Std 12pt. (We're using Version 2.050; PS 2.000; hotconv 1.0.51;makeotf.lib2.0.18671). Open LibreOffice 3.3.1. Quit Libreoffice.
    InDesign activates (it was the last app open) and pops up the Missing Fonts dialog, saying that Utopia Std is no longer on the system, and every character changes to a missing-font rectangle.
    A few seconds later all the rectangles go away. But this is not proper behavior...

  • How to write script to apply character style?

    Hi,
    I'm on a Macbook pro and without a number pad so I can't assign a shortcut for the character styles. I did hear of a roundabout solution where you can assign a shortcut to a script which applies the character styles. Can anyone write this script?
    My character style is called 'Features bold'.
    I'm new to scripting, sorry if this is a dumb question.
    Cheers

    Hi,
    1. Save this code as .jsx file inside your Script Panel folder
    2. Apply a shortcut using Edit:Keyboard shortcuts... menu
    Option to choose:
    suggest to choose an option "context": "Text", so you can use more shortcuts which are busy with other contexts.
    #target indesign
    if (app.selection && app.selection[0].hasOwnProperty ("baselineShift") ) {
      var cName = "Features bold";
      var mCstyle = app.activeDocument.characterStyles.item(cName);
      if (mCstyle.isValid)
           app.selection[0].applyCharacterStyle(mCstyle);
      else
           alert ("CharStyle: " + cName + " not found");
    else
      alert ("Some text supposed to be selected...");
    Jarek

  • [JS][CS3]Applying Character Style to First Word

    I am a noob as far as Javascript  is concerned, and I was hoping for a little guidance.
    Here's my scenario: I have a book that has been typeset all in one file; the main content is all in one story. I want to select the first word of every text frame on each page and apply a character style. My goal is to utilize this character style to indicate page breaks in the XML--I'll map the style to a specific tag.
    So far I have this poor specimen:
    var myDocument = app.activeDocument;
    var myPage = myDocument.pages.item(1);
    var myTextFrame = myPage.textFrames.item(0);
    if( app.activeDocument.stories[0].paragraphs[0].words[0] != null )
    myTextFrame.paragraphs.item(0).words.item(0).appliedCharacterStyle =
    myDocument.characterStyles.item('foo');
    I know, I haven't set up any sort of loop yet (which will be trickier given the fact that there will be blank versos, etc). What I'm trying to do in this is to select the first word in the first paragraph on the second page--which it does in fact do. Problem is, the first paragraph on the second page starts on the first page, so I'm selecting that a word on the first page, not the second page.
    As I said, lots of work to do but a little help on getting to the right word would be most appreciated.

    Well, you were on the right track, but testing 'myText' fails if there is no text frame on a page because it fails one line earlier
    >var myTextFrame = myPage.textFrames.item(0);
    just before this, you should test the number of text frames:
    if (myPage.textFrames.length > 0)
      ... your stuff ..
    Only use this if you are absolutely positive there is just a single text frame on each page! A slightly better way would be to always loop over each textframe:
    for (frames=0; frames<myPage.textFrames.length; frames++)
      var myTextFrame = myPage.textFrames.item(frames);
      ..etc.
    in which case you also don't have to test its length first (the loop will not be executed if there are zero text frames).
    [Techy] Since you have only one continuous story, an even better way would be to loop over the textframes of that story alone. You have to identify the story somehow, and I usually click the text cursor in the one I need:
    myStory = app.selection[0].parentStory;
    or you can rely on the fact that the story starts in the only text frame on page 1:
    myStory = app.activeDocument.pages[0].stories[0];
    (I think that oughta work.) Then, each frame of this story up till the end can be found in the array
    myStory.textContainers
    which are usually text frames. You can loop over these using
    for (frame=0; frame<myStory.textContainers.length; frame++)
      myTextFrame = myStory.textContainers[frame];
    ..etc.

  • [CS5 JS] Problem in Applying character styles xml tag names

    Hi,
    e.g. 1
    <italic>This is a italic text with <sup>superscript value</sup></italic>
    e.g.2
    <sup>This is a superscript text with <bold>Bold superscript</bold></sup>
    <italic>  mapped to character style "italic" and
    <sup> mapped to character style "sup"
    In my java script I already mapped the xml tags to specific character styles. In some of the cases (see e.g.1 and e.g.2) I need to map it to other character styles.
    In e.g.1 I need to apply a new character styles "italicSup" for the text "superscript value" same way
    In e.g.2 I need to apply a new character styles "BoldSup" for the text "Bold superscript".
    Can any know how to do this?
    Green4ever

    FYI, I am using
    Win Xp-SP2, CS5 7.0.3

  • With Grep SUPERSCRİPT apply character style

    I want the script with
    contained in document SUPERSCRIPT
    apply a character style
    app.findGrepPreferences = app.changeGrepPreferences = null;      
    app.findGrepPreferences.findWhat = Position.SUPERSCRIPT; //??
    //app.changeGrepPreferences.changeTo = "";
    app.changeGrepPreferences.appliedCharacterStyle = "myChar";
    app.activeDocument.changeGrep(); 
    app.findGrepPreferences = app.changeGrepPreferences = null;

    Try this,
    app.findGrepPreferences = app.changeGrepPreferences = null;     
    app.findGrepPreferences.position = Position.SUPERSCRIPT;
    app.changeGrepPreferences.appliedCharacterStyle = "myCar1";
    app.activeDocument.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.position = Position.SUBSCRIPT;
    app.changeGrepPreferences.appliedCharacterStyle = "myCar2";
    app.activeDocument.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    Vandy

  • InDesign crashes while exporting to PDF

    I have one PDF that after placing in InDesign cannot be exported to PDF
    InDesign crashes on Windows and Macintosh, versions from CS3 to CC
    Any ideas what can be wrong with my PDF?

    I reckon you might find that you have font clashes as your PDF is being created. I had a similar issue a few weeks back where I had created a Brochure, sent it to the client, went through rounds of amends, and the final round of amends prior to print sign off was sent in a word document. When I opened the word doc, I copied and pasted the amends, all looked fine, so I created one last PDF... crash.
    I ahve a suspicion that word auto-activated a font that didn't agree with fonts within the InDesign file. I deactivated many fonts, restarted my Mac and hey presto... sorted!
    Now, the PDF that you imported into your InDesign file may well be the culprit activating a dodgy font, and this becomes a bit problematical. So, you could open it in Photoshop and save it as a high res image, or you could open it in Illustrator and hopefully all text has remained in place and will enable you to ouline fonts and save it as an illustrator file... BUT, you must advise and get your client to check the contents of the resultant file if you go down either of these routes.

  • InDesign CS5.5 crashes while applying Template to a page

    Hi,
    We installed Adobe InDesign CS5.5. on 10 Windows XP SP3 32-bit workstations with 2 GB RAM. On every computer, when a user tries to apply a template to a page in a .indd document, InDesign immediately shuts down without displaying any error messages. Using the Sysinternals Tools and Dr.Watson, I think that the faulty plugin might be this one: C:\Program Files\Adobe\Adobe InDesign CS5.5\Plug-Ins\Layout\PAGES PANEL.APLN.
    Here's a part of the drwtsn32.log file (the full log can be made available upon request):
    Une exception d'application s'est produite :
            App : C:\Program Files\Adobe\Adobe InDesign CS5.5\InDesign.exe (pid=2844)
            Lorsque : 2012-08-13 @ 14:32:37.017
            Numéro d'exception : c0000005 (violation d'accès)
    *----> Liste des tâches <----*
       0 System Process
       4 Error 0xD0000022
    452 Error 0xD0000022
    508 Error 0xD0000022
    532 Error 0xD0000022
    576 Error 0xD0000022
    588 Error 0xD0000022
    764 Error 0xD0000022
    *----> Suivi arrière de la pile <----*
    WARNING: Stack unwind information not available. Following frames may be wrong.
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Program Files\Adobe\Adobe InDesign CS5.5\Required\LAYOUT.RPLN -
    ChildEBP RetAddr  Args to Child             
    06606b88 0625bf00 00020002 0408010b 0a8b1984 CJKGRID+0x20b55
    0aa2915c 0aa1f130 0aa21a50 0aa1cb90 0aa1ba60 0x625bf00
    0aa1d060 8108244c 000132f9 8b157500 c985044e LAYOUT+0xf130
    8bf18b56 00000000 00000000 00000000 00000000 0x8108244c
    Has anybody ever experienced this issue ? Are there known workarounds ?
    Let me know if you need additionnal information.
    Thank you in advance !
    LR

    Hi,
    I am not sure if this is a "Master Page since we use a French version (the functionnality is  named "Gabarit" in French), so here is a printscreen which shows what our users try to do:
    Immediately after the drop is completed, InDesign shuts down without further notice as described before.
    I fully patched one machine to 7.5.3, rebooted it and it still does not work.
    I know 2 GB is a little bit short, but since this is currently a corporate standard in my customer's organization, I will need to be sure that this is the direct and only cause before any upgrade request can be made.
    Thank you for your help.

  • Indesign crashes when editing GREP styles

    I'm using Indesign CS6 on a mac.  I have GREP styles applied to a certain paragraph style, and every time I go in to try and edit the GREP styles, ID crashes.  I have another, completely separate file, which also uses GREP styles, but so far hasn't had a problem with me editing them.  I tried the suggested solution of exporting to .idml and recreating the file, but when I try to open the idml file, ID crashes again.  Is my best option to clear my preferences?  Is there anything else I can try?

    It's when I try to edit any of the four GREP styles I have applied to that paragraph style.  If I try to edit GREP styles for any of my other paragraph styles, ID handles it fine.  I made a new paragraph style that was identical to the troublesome one (just by applying the same styles, not by duplicating it), and without any GREP styles.  When I went to delete the old one and replace it with the new one, ID crashed again.  So it sounds as though this paragraph style is what is causing the problem, but I can't seem to get rid of it.

Maybe you are looking for