1 Reply Latest reply on Jan 10, 2013 6:07 AM by Yotun

    Extracting texts from Paragraph with RangeStyle

    Yotun

      Hi!

      I need help extracting text from paragraph maintaining style applied directly to the characters without going over all the characters.
      Prerequisite - bypassing the need is by paragraps.
      For example:"A string representation of a FontFamily value, possibly including fallback values or indexes within a font file, or a URI where the font family is packaged.
      For more information on the syntax, see Fontfamily."

       

      In the myParagraph.TextStyleRanges(1).Texts(1) stored text with style same "color=blue", and the Contents  is really only part of the FIRST Paragraph.

      In the myParagraph.TextStyleRanges(2).Texts(1) stored text with style same "bold=true", but in the Contents stored mixed text, from First and Second Paragraph simultaneously.

        • 1. Re: Extracting texts from Paragraph with RangeStyle
          Yotun Level 1

          For rangeIndex = 1 To _story.TextStyleRanges.Count

          Dim mRange As InDesign.TextStyleRange = _story.TextStyleRanges(rangeIndex)

          rStart = mRange.Characters(1).InsertionPoints(1).index

                  rEnd = mRange.Characters(-1).InsertionPoints(1).index

                  For paragraphIndex = 1 To mRange.Paragraphs.Count

                          Dim mParagraph As InDesign.Paragraph = mRange.Paragraphs(paragraphIndex)

                          If mParagraph.ParentTextFrames.count > 0 Then

                             pStart = mParagraph.Characters(1).InsertionPoints(1).index

                             pEnd = mParagraph.Characters(-1).InsertionPoints(1).index

                             If pStart >= rStart Then

                              If IsNothing(mTag) = False Then

                                   ' new paragraph

                             End If

                             Dim _max = Math.Max(rStart, pStart)

                             Dim _min = Math.Min(rEnd, pEnd)

                             pText = (_XMLCorrect(Mid(mRange.Texts(1).contents, _max - rStart + 1, _min - _max + 1)))

                                  ' StyledText , bold or  underline or Italic from mRange

                           End If

                 Next

          Next