Skip to main content
Amr.Hamdy
Known Participant
June 2, 2023
Answered

Search in Paragraph styles

  • June 2, 2023
  • 4 replies
  • 1924 views

Dear All,

I have a big project that has around 4000 pages.

The indd files include 29 paragraph styles that are in English, and I would like to change some attribute in the paragraph styles like direction, composer, and so on.

I am aware that I can use InDesign's find and replace feature, but it's for 1 by 1 par. Styles only. Is there any script that can search in multi paragraph styles at once?

I would like you help in this really, because it will save a lot of times of repeated steps.

This topic has been closed for replies.
Correct answer m1b

Well you can do that by first getting a reference to the ParagraphStyle, and then settings the properties. Here's the ParagraphStyle documentation.

 

Here is some code that gets a reference to a paragraph style and then sets some of its properties:

var doc = app.activeDocument,
    myParagraphStyle = doc.paragraphStyles.itemByName('My Paragraph Style');

// example of changing some properties
myParagraphStyle.properties = {
    composer: 'Adobe Paragraph Composer',
    characterDirection: CharacterDirectionOptions.RIGHT_TO_LEFT_DIRECTION,
    hypenation: false,
    pointSize: 11,
}

/*
Properties of ParagraphStyle:
  •  alignToBaseline
  •  allowArbitraryHyphenation
  •  appliedFont
  •  appliedLanguage
  •  appliedNumberingList
  •  autoLeading
  •  autoTcy
  •  autoTcyIncludeRoman
  •  balanceRaggedLines
  •  basedOn
  •  baselineShift
  •  bulletChar
  •  bulletsAlignment
  •  bulletsAndNumberingListType
  •  bulletsCharacterStyle
  •  bulletsTextAfter
  •  bunriKinshi
  •  capitalization
  •  characterAlignment
  •  characterDirection
  •  characterRotation
  •  cjkGridTracking
  •  composer
  •  designAxes
  •  desiredGlyphScaling
  •  desiredLetterSpacing
  •  desiredWordSpacing
  •  diacriticPosition
  •  digitsType
  •  dropCapCharacters
  •  dropCapLines
  •  dropCapStyle
  •  dropcapDetail
  •  emitCss
  •  endJoin
  •  eventListeners
  •  events
  •  fillColor
  •  fillTint
  •  firstLineIndent
  •  fontStyle
  •  glyphForm
  •  gradientFillAngle
  •  gradientFillLength
  •  gradientFillStart
  •  gradientStrokeAngle
  •  gradientStrokeLength
  •  gradientStrokeStart
  •  gridAlignFirstLineOnly
  •  gridAlignment
  •  gridGyoudori
  •  horizontalScale
  •  hyphenWeight
  •  hyphenateAcrossColumns
  •  hyphenateAfterFirst
  •  hyphenateBeforeLast
  •  hyphenateCapitalizedWords
  •  hyphenateLadderLimit
  •  hyphenateLastWord
  •  hyphenateWordsLongerThan
  •  hyphenation
  •  hyphenationZone
  •  ignoreEdgeAlignment
  •  imported
  •  includeClass
  •  jidori
  •  justification
  •  kashidas
  •  keepAllLinesTogether
  •  keepFirstLines
  •  keepLastLines
  •  keepLinesTogether
  •  keepRuleAboveInFrame
  •  keepWithNext
  •  keepWithPrevious
  •  kentenAlignment
  •  kentenCharacterSet
  •  kentenCustomCharacter
  •  kentenFillColor
  •  kentenFont
  •  kentenFontSize
  •  kentenFontStyle
  •  kentenKind
  •  kentenOverprintFill
  •  kentenOverprintStroke
  •  kentenPlacement
  •  kentenPosition
  •  kentenStrokeColor
  •  kentenStrokeTint
  •  kentenTint
  •  kentenWeight
  •  kentenXScale
  •  kentenYScale
  •  kerningMethod
  •  keyboardDirection
  •  kinsokuHangType
  •  kinsokuSet
  •  kinsokuType
  •  label
  •  lastLineIndent
  •  leading
  •  leadingAki
  •  leadingModel
  •  leftIndent
  •  ligatures
  •  maximumGlyphScaling
  •  maximumLetterSpacing
  •  maximumWordSpacing
  •  mergeConsecutiveParaBorders
  •  minimumGlyphScaling
  •  minimumLetterSpacing
  •  minimumWordSpacing
  •  miterLimit
  •  mojikumi
  •  name
  •  nestedGrepStyles
  •  nestedLineStyles
  •  nestedStyles
  •  nextStyle
  •  noBreak
  •  numberingAlignment
  •  numberingApplyRestartPolicy
  •  numberingCharacterStyle
  •  numberingContinue
  •  numberingExpression
  •  numberingFormat
  •  numberingLevel
  •  numberingRestartPolicies
  •  numberingStartAt
  •  otfContextualAlternate
  •  otfDiscretionaryLigature
  •  otfFigureStyle
  •  otfFraction
  •  otfHVKana
  •  otfHistorical
  •  otfJustificationAlternate
  •  otfLocale
  •  otfMark
  •  otfOrdinal
  •  otfOverlapSwash
  •  otfProportionalMetrics
  •  otfRomanItalics
  •  otfSlashedZero
  •  otfStretchedAlternate
  •  otfStylisticAlternate
  •  otfStylisticSets
  •  otfSwash
  •  otfTitling
  •  overprintFill
  •  overprintStroke
  •  paragraphBorderBottomLeftCornerOption
  •  paragraphBorderBottomLeftCornerRadius
  •  paragraphBorderBottomLineWeight
  •  paragraphBorderBottomOffset
  •  paragraphBorderBottomOrigin
  •  paragraphBorderBottomRightCornerOption
  •  paragraphBorderBottomRightCornerRadius
  •  paragraphBorderColor
  •  paragraphBorderDisplayIfSplits
  •  paragraphBorderGapColor
  •  paragraphBorderGapOverprint
  •  paragraphBorderGapTint
  •  paragraphBorderLeftLineWeight
  •  paragraphBorderLeftOffset
  •  paragraphBorderOn
  •  paragraphBorderOverprint
  •  paragraphBorderRightLineWeight
  •  paragraphBorderRightOffset
  •  paragraphBorderStrokeEndCap
  •  paragraphBorderStrokeEndJoin
  •  paragraphBorderTint
  •  paragraphBorderTopLeftCornerOption
  •  paragraphBorderTopLeftCornerRadius
  •  paragraphBorderTopLineWeight
  •  paragraphBorderTopOffset
  •  paragraphBorderTopOrigin
  •  paragraphBorderTopRightCornerOption
  •  paragraphBorderTopRightCornerRadius
  •  paragraphBorderType
  •  paragraphBorderWidth
  •  paragraphDirection
  •  paragraphGyoudori
  •  paragraphJustification
  •  paragraphKashidaWidth
  •  paragraphShadingBottomLeftCornerOption
  •  paragraphShadingBottomLeftCornerRadius
  •  paragraphShadingBottomOffset
  •  paragraphShadingBottomOrigin
  •  paragraphShadingBottomRightCornerOption
  •  paragraphShadingBottomRightCornerRadius
  •  paragraphShadingClipToFrame
  •  paragraphShadingColor
  •  paragraphShadingLeftOffset
  •  paragraphShadingOn
  •  paragraphShadingOverprint
  •  paragraphShadingRightOffset
  •  paragraphShadingSuppressPrinting
  •  paragraphShadingTint
  •  paragraphShadingTopLeftCornerOption
  •  paragraphShadingTopLeftCornerRadius
  •  paragraphShadingTopOffset
  •  paragraphShadingTopOrigin
  •  paragraphShadingTopRightCornerOption
  •  paragraphShadingTopRightCornerRadius
  •  paragraphShadingWidth
  •  pointSize
  •  position
  •  positionalForm
  •  preferences
  •  previewColor
  •  providerHyphenationStyle
  •  rensuuji
  •  rightIndent
  •  rotateSingleByteCharacters
  •  rubyAlignment
  •  rubyAutoAlign
  •  rubyAutoScaling
  •  rubyAutoTcyAutoScale
  •  rubyAutoTcyDigits
  •  rubyAutoTcyIncludeRoman
  •  rubyFill
  •  rubyFont
  •  rubyFontSize
  •  rubyFontStyle
  •  rubyOpenTypePro
  •  rubyOverhang
  •  rubyOverprintFill
  •  rubyOverprintStroke
  •  rubyParentOverhangAmount
  •  rubyParentScalingPercent
  •  rubyParentSpacing
  •  rubyPosition
  •  rubyStroke
  •  rubyStrokeTint
  •  rubyTint
  •  rubyType
  •  rubyWeight
  •  rubyXOffset
  •  rubyXScale
  •  rubyYOffset
  •  rubyYScale
  •  ruleAbove
  •  ruleAboveColor
  •  ruleAboveGapColor
  •  ruleAboveGapOverprint
  •  ruleAboveGapTint
  •  ruleAboveLeftIndent
  •  ruleAboveLineWeight
  •  ruleAboveOffset
  •  ruleAboveOverprint
  •  ruleAboveRightIndent
  •  ruleAboveTint
  •  ruleAboveType
  •  ruleAboveWidth
  •  ruleBelow
  •  ruleBelowColor
  •  ruleBelowGapColor
  •  ruleBelowGapOverprint
  •  ruleBelowGapTint
  •  ruleBelowLeftIndent
  •  ruleBelowLineWeight
  •  ruleBelowOffset
  •  ruleBelowOverprint
  •  ruleBelowRightIndent
  •  ruleBelowTint
  •  ruleBelowType
  •  ruleBelowWidth
  •  sameParaStyleSpacing
  •  scaleAffectsLineHeight
  •  shataiAdjustRotation
  •  shataiAdjustTsume
  •  shataiDegreeAngle
  •  shataiMagnification
  •  singleWordJustification
  •  skew
  •  spaceAfter
  •  spaceBefore
  •  spanColumnMinSpaceAfter
  •  spanColumnMinSpaceBefore
  •  spanColumnType
  •  spanSplitColumnCount
  •  splitColumnInsideGutter
  •  splitColumnOutsideGutter
  •  splitDocument
  •  startParagraph
  •  strikeThroughColor
  •  strikeThroughGapColor
  •  strikeThroughGapOverprint
  •  strikeThroughGapTint
  •  strikeThroughOffset
  •  strikeThroughOverprint
  •  strikeThroughTint
  •  strikeThroughType
  •  strikeThroughWeight
  •  strikeThru
  •  strokeAlignment
  •  strokeColor
  •  strokeTint
  •  strokeWeight
  •  styleExportTagMaps
  •  styleUniqueId
  •  tabList
  •  tabStops
  •  tatechuyoko
  •  tatechuyokoXOffset
  •  tatechuyokoYOffset
  •  tracking
  •  trailingAki
  •  treatIdeographicSpaceAsSpace
  •  tsume
  •  underline
  •  underlineColor
  •  underlineGapColor
  •  underlineGapOverprint
  •  underlineGapTint
  •  underlineOffset
  •  underlineOverprint
  •  underlineTint
  •  underlineType
  •  underlineWeight
  •  verticalScale
  •  warichu
  •  warichuAlignment
  •  warichuCharsAfterBreak
  •  warichuCharsBeforeBreak
  •  warichuLineSpacing
  •  warichuLines
  •  warichuSize
  •  xOffsetDiacritic
  •  yOffsetDiacritic
*/

 Hope that gives you something to work with.

- Mark

4 replies

TᴀW
Legend
June 12, 2023

If you'd like a convenient, off-the-shelf solution, check out my (not free) Search in Styles - Id-Extras.com

You set up the regular InDesign find/change dialog as usual, as though you wanted to make changes in regular text. But then, instead of clicking on Find, you run the script Search in Styles.

It then performs your find/change on some or all of the paragraph or character styles in the document, not on the live text, but on the styles.

However, bear in mind that this will only let you search for properties in the styles that you can search for in text itself.

So, of those you've mentioned above, you'll be fine to search for font size, paragraph direction, and even paragraph composer. But you mentioned hyphenation. Hyphenation is not something that you can search for with InDesign's regular find/change, unfortunately. And therefore you would not be able to search for it with the Search in Styles script either.

Amr.Hamdy
Amr.HamdyAuthor
Known Participant
June 14, 2023

Hello Taw.

thanks for offer, i will give it a try, as i saw the price will be so much high for me as i'm personal not a company.

antway, thanks for your geat help.

Phil 815
Inspiring
June 6, 2023

I assume you could quickly update them by doing something like this:

var page = app.documents.item(0);
var param = page.paragraphStyles.everyItem().appliedFont = "nimbus sans"

 If there are unique changes for each style that need to be made you'd just loop through the collection instead of applying to all of them at once.

Amr.Hamdy
Amr.HamdyAuthor
Known Participant
June 10, 2023

Thanks fill, but i figuer our that this code is for change the fonts used in the paragraphs you mean ?!
if so, what should i change in the code to change the direction, alignment, font size, ect. ?

 

it will be good to send me an example and i could continue.

Robert at ID-Tasker
Legend
June 10, 2023

In the code above you can replace .appliedFont with required property from the 2nd reply from @m1b  with correct parameter. 

 

More info about all the properties you can find here:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html

 

Peter Kahrel
Community Expert
Community Expert
June 2, 2023

InDesign's find-replace is for text only. To change attributes in paragraph styles, you can do that manually in the Paragraph Style Options window, or you can script it.

 

If the paragraph styles were set up using the based-on feature, maybe you need to change only one style (if you're very lucky) and the change will propagate to all styles. Or maybe the styles are based on two or three styles, in which case it's still easier simply to make the change manually. Only when you'd have to change a lot of styles would it be useful to do a script.

Amr.Hamdy
Amr.HamdyAuthor
Known Participant
June 10, 2023

Thanks peter for your reply,

InDesign Find-replace didn't work with me as there are a lot of them need to change.

also the paragraph styles not build on 1 as main, they seperated every one in the file, that's why i asked for the way or sscripting it.

m1b
Community Expert
Community Expert
June 2, 2023

Hi @Amr.Hamdy Do you just want to edit the paragraph style to change direction, composer etc? That will apply to any paragraphs with that style in most cases. 
- Mark

Amr.Hamdy
Amr.HamdyAuthor
Known Participant
June 10, 2023

Hello Mark,

Yes, I need only change the attributs in Paragraph Styles like Composer, Font Size, Direction, Hyphnation, etc.

m1b
Community Expert
Community Expert
June 14, 2023

It's Great help mark, thanks in advance.

Just 1 question; in this code:

myParagraphStyle = doc.paragraphStyles.itemByName('My Paragraph Style'); 

Should I change ('My Paragraph Style') to my paragraph style in the doc?

Is there any code can search in the paragraph styles in the file instead of insert paragraph style names.?

 

I hope that my question not bothering you


Should I change ('My Paragraph Style') to my paragraph style in the doc?

Yes.

 

Is there any code can search in the paragraph styles in the file instead of insert paragraph style names.?

Sure it can be done in a script. Can you describe what you need?

 

For example, if you want to set certain properties of every paragraph style in the document, you can do this:

/**
 * Set properties of ALL paragraph styles in acrtive document.
 * @7111211 m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/search-in-paragraph-styles/m-p/13855341
 */
function main() {

    var doc = app.activeDocument,
        myParagraphStyles = doc.paragraphStyleGroups.everyItem().paragraphStyles.everyItem();

    // example of changing some properties
    myParagraphStyles.properties = {
        composer: 'Adobe Paragraph Composer',
        characterDirection: CharacterDirectionOptions.RIGHT_TO_LEFT_DIRECTION,
        hyphenation: false,
        pointSize: 11,
    };

}

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Adjust Paragraph Styles');

- Mark