• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get all properties of ParagraphStyle as object as in paragraphStyle Panel using Javascript

Engaged ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Is there anyway to get ParagraphStyle Properties listed in ParagraphStyle Panel as a single object using javascript??Screenshot 2022-11-16 103140.png

TOPICS
How to , Scripting

Views

247

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Nov 16, 2022 Nov 16, 2022
myParagraphStyle.properties.toSource();

which returns something like:

{ name: "foo", imported: false, basedOn: "[Aucun style]", nextStyle: resolve("/document[@id=1]//paragraph-style[@id=227]"), alignToBaseline: false, firstLineIndent: 0, leftIndent: 0, rightIndent: 0, spaceBefore: 0, spaceAfter: 0, balanceRaggedLines: ({}), justification: ({}), singleWordJustification: ({}), autoLeading: 120, dropCapLines: 0, dropCapCharacters: 0, keepLinesTogether: false, keepAllLinesTogether: false, keepWithNext
...

Votes

Translate

Translate
People's Champ ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

myParagraphStyle.properties.toSource();

which returns something like:

{ name: "foo", imported: false, basedOn: "[Aucun style]", nextStyle: resolve("/document[@id=1]//paragraph-style[@id=227]"), alignToBaseline: false, firstLineIndent: 0, leftIndent: 0, rightIndent: 0, spaceBefore: 0, spaceAfter: 0, balanceRaggedLines: ({}), justification: ({}), singleWordJustification: ({}), autoLeading: 120, dropCapLines: 0, dropCapCharacters: 0, keepLinesTogether: false, keepAllLinesTogether: false, keepWithNext: 0, keepFirstLines: 2, keepLastLines: 2, startParagraph: ({}), composer: "Compositeur de paragraphe Adobe", minimumWordSpacing: 80, maximumWordSpacing: 133, desiredWordSpacing: 100, minimumLetterSpacing: 0, maximumLetterSpacing: 0, desiredLetterSpacing: 0, minimumGlyphScaling: 100, maximumGlyphScaling: 100, desiredGlyphScaling: 100, ruleAbove: false, ruleAboveOverprint: false, ruleAboveLineWeight: 1, ruleAboveTint: -1, ruleAboveOffset: 0, ruleAboveLeftIndent: 0, ruleAboveRightIndent: 0, ruleAboveWidth: ({}), ruleAboveColor: "Text Color", ruleAboveGapColor: resolve("/document[@id=1]//swatch[@id=14]"), ruleAboveGapTint: -1, ruleAboveGapOverprint: false, ruleAboveType: resolve("/document[@id=1]/stroke-style[@id=23081]"), ruleBelow: false, ruleBelowLineWeight: 1, ruleBelowTint: -1, ruleBelowOffset: 0, ruleBelowLeftIndent: 0, ruleBelowRightIndent: 0, ruleBelowWidth: ({}), ruleBelowColor: "Text Color", ruleBelowGapColor: resolve("/document[@id=1]//swatch[@id=14]"), ruleBelowGapTint: -1, ruleBelowType: resolve("/document[@id=1]/stroke-style[@id=23081]"), hyphenateCapitalizedWords: true, hyphenation: true, hyphenateBeforeLast: 2, hyphenateAfterFirst: 2, hyphenateWordsLongerThan: 5, hyphenateLadderLimit: 3, hyphenationZone: 12.7, hyphenWeight: 5, dropCapStyle: resolve("/document[@id=1]//character-style[@id=124]"), tabList: [], appliedFont: resolve("/font[@name=\"Minion Pro	Regular\"]"), fontStyle: "Regular", pointSize: 12, leading: ({}), kerningMethod: "Métrique", tracking: 0, capitalization: ({}), position: ({}), underline: false, strikeThru: false, ligatures: true, noBreak: false, horizontalScale: 100, verticalScale: 100, baselineShift: 0, skew: 0, fillTint: -1, strokeTint: -1, strokeWeight: 1, overprintStroke: false, overprintFill: false, otfFigureStyle: ({}), otfOrdinal: false, otfFraction: false, otfDiscretionaryLigature: false, otfTitling: false, otfContextualAlternate: true, otfSwash: false, underlineColor: "Text Color", underlineGapColor: resolve("/document[@id=1]//swatch[@id=14]"), underlineTint: -1, underlineGapTint: -1, underlineOverprint: false, underlineGapOverprint: false, underlineType: resolve("/document[@id=1]/stroke-style[@id=23081]"), underlineOffset: -9999, underlineWeight: -9999, strikeThroughColor: "Text Color", strikeThroughGapColor: resolve("/document[@id=1]//swatch[@id=14]"), strikeThroughTint: -1, strikeThroughGapTint: -1, strikeThroughOverprint: false, strikeThroughGapOverprint: false, strikeThroughType: resolve("/document[@id=1]/stroke-style[@id=23081]"), strikeThroughOffset: -9999, strikeThroughWeight: -9999, fillColor: resolve("/document[@id=1]//color[@id=20]"), strokeColor: resolve("/document[@id=1]//swatch[@id=14]"), appliedLanguage: resolve("/language-with-vendors[@id=88]"), keepWithPrevious: false, spanSplitColumnCount: ({}), spanColumnType: ({}), splitColumnInsideGutter: 2.11666666666667, splitColumnOutsideGutter: 0, spanColumnMinSpaceBefore: 0, spanColumnMinSpaceAfter: 0, splitDocument: false, emitCss: true, styleUniqueId: "e5912a6c-a332-4e8c-9a79-68159a492bc0", paragraphShadingLeftOffset: 0, paragraphShadingRightOffset: 0, paragraphShadingTopOffset: 0, paragraphShadingBottomOffset: 0, paragraphShadingWidth: ({}), paragraphShadingTopOrigin: ({}), paragraphShadingBottomOrigin: ({}), paragraphShadingClipToFrame: false, paragraphShadingSuppressPrinting: false, paragraphShadingOn: false, paragraphShadingOverprint: false, paragraphShadingTint: 20, paragraphShadingColor: resolve("/document[@id=1]//color[@id=11]"), includeClass: true, paragraphBorderOn: false, paragraphBorderOverprint: false, paragraphBorderTint: -1, paragraphBorderColor: resolve("/document[@id=1]//color[@id=11]"), paragraphBorderGapOverprint: false, paragraphBorderGapTint: -1, paragraphBorderGapColor: resolve("/document[@id=1]//swatch[@id=14]"), paragraphBorderType: resolve("/document[@id=1]/stroke-style[@id=23081]"), paragraphBorderLeftLineWeight: 1, paragraphBorderTopLineWeight: 1, paragraphBorderRightLineWeight: 1, paragraphBorderBottomLineWeight: 1, paragraphBorderStrokeEndCap: ({}), paragraphBorderStrokeEndJoin: ({}), paragraphShadingTopLeftCornerRadius: 12, paragraphShadingTopLeftCornerOption: ({}), paragraphShadingTopRightCornerRadius: 12, paragraphShadingTopRightCornerOption: ({}), paragraphShadingBottomLeftCornerRadius: 12, paragraphShadingBottomLeftCornerOption: ({}), paragraphShadingBottomRightCornerRadius: 12, paragraphShadingBottomRightCornerOption: ({}), paragraphBorderTopLeftCornerRadius: 12, paragraphBorderTopLeftCornerOption: ({}), paragraphBorderTopRightCornerRadius: 12, paragraphBorderTopRightCornerOption: ({}), paragraphBorderBottomLeftCornerRadius: 12, paragraphBorderBottomLeftCornerOption: ({}), paragraphBorderBottomRightCornerRadius: 12, paragraphBorderBottomRightCornerOption: ({}), paragraphBorderWidth: ({}), paragraphBorderTopOrigin: ({}), paragraphBorderBottomOrigin: ({}), paragraphBorderLeftOffset: 0, paragraphBorderRightOffset: 0, paragraphBorderTopOffset: 0, paragraphBorderBottomOffset: 0, paragraphBorderDisplayIfSplits: false, providerHyphenationStyle: ({}), mergeConsecutiveParaBorders: true, sameParaStyleSpacing: ({}), paragraphKashidaWidth: 2, designAxes: [], lastLineIndent: 0, hyphenateLastWord: true, otfSlashedZero: false, otfHistorical: false, otfStylisticSets: 0, gradientFillLength: -1, gradientFillAngle: 0, gradientStrokeLength: -1, gradientStrokeAngle: 0, gradientFillStart: [0, 0], gradientStrokeStart: [0, 0], ruleBelowOverprint: false, ruleBelowGapOverprint: false, dropcapDetail: 1, hyphenateAcrossColumns: true, keepRuleAboveInFrame: false, ignoreEdgeAlignment: false, otfMark: true, otfLocale: true, positionalForm: ({}), previewColor: ({}), paragraphDirection: ({}), paragraphJustification: ({}), miterLimit: 4, strokeAlignment: ({}), endJoin: ({}), otfOverlapSwash: false, otfStylisticAlternate: false, otfJustificationAlternate: false, otfStretchedAlternate: false, characterDirection: ({}), keyboardDirection: ({}), digitsType: ({}), kashidas: ({}), diacriticPosition: ({}), xOffsetDiacritic: 0, yOffsetDiacritic: 0, characterAlignment: ({}), tsume: 0, leadingAki: -1, trailingAki: -1, characterRotation: 0, jidori: 0, shataiMagnification: 0, shataiDegreeAngle: 4500, shataiAdjustRotation: false, shataiAdjustTsume: true, tatechuyoko: false, tatechuyokoXOffset: 0, tatechuyokoYOffset: 0, kentenFillColor: "Text Color", kentenStrokeColor: "Text Color", kentenTint: -1, kentenStrokeTint: -1, kentenWeight: -1, kentenOverprintFill: ({}), kentenOverprintStroke: ({}), kentenKind: ({}), kentenPlacement: 0, kentenAlignment: ({}), kentenPosition: ({}), kentenFont: null, kentenFontStyle: ({}), kentenFontSize: -1, kentenXScale: 100, kentenYScale: 100, kentenCustomCharacter: "", kentenCharacterSet: ({}), rubyFill: "Text Color", rubyStroke: "Text Color", rubyTint: -1, rubyWeight: -1, rubyOverprintFill: ({}), rubyOverprintStroke: ({}), rubyStrokeTint: -1, rubyFont: null, rubyFontStyle: ({}), rubyFontSize: -1, rubyOpenTypePro: true, rubyXScale: 100, rubyYScale: 100, rubyType: ({}), rubyAlignment: ({}), rubyPosition: ({}), rubyXOffset: 0, rubyYOffset: 0, rubyParentSpacing: ({}), rubyAutoAlign: true, rubyOverhang: false, rubyAutoScaling: false, rubyParentScalingPercent: 66, rubyParentOverhangAmount: ({}), warichu: false, warichuSize: 50, warichuLines: 2, warichuLineSpacing: 0, warichuAlignment: ({}), warichuCharsAfterBreak: 2, warichuCharsBeforeBreak: 2, otfProportionalMetrics: false, otfHVKana: false, otfRomanItalics: false, scaleAffectsLineHeight: false, cjkGridTracking: false, glyphForm: ({}), gridAlignFirstLineOnly: false, gridAlignment: ({}), gridGyoudori: 0, autoTcy: 0, autoTcyIncludeRoman: false, kinsokuSet: ({}), kinsokuType: ({}), kinsokuHangType: ({}), bunriKinshi: true, mojikumi: ({}), rensuuji: true, rotateSingleByteCharacters: false, leadingModel: ({}), rubyAutoTcyDigits: 0, rubyAutoTcyIncludeRoman: false, rubyAutoTcyAutoScale: true, treatIdeographicSpaceAsSpace: true, allowArbitraryHyphenation: false, paragraphGyoudori: false, bulletsAndNumberingListType: ({}), bulletChar: resolve("/document[@id=1]//paragraph-style[@id=227]/@bullet-char"), bulletsCharacterStyle: resolve("/document[@id=1]//character-style[@id=124]"), numberingCharacterStyle: resolve("/document[@id=1]//character-style[@id=124]"), numberingExpression: "^#.^t", numberingRestartPolicies: resolve("/document[@id=1]//paragraph-style[@id=227]/@numbering-restart-policies"), bulletsTextAfter: "^t", appliedNumberingList: resolve("/document[@id=1]//numbering-list[@id=62]"), numberingLevel: 1, numberingFormat: "1, 2, 3, 4...", numberingContinue: true, numberingStartAt: 1, numberingApplyRestartPolicy: true, bulletsAlignment: ({}), numberingAlignment: ({}), id: 227, label: "", parent: resolve("/document[@id=1]"), index: 2 }

 

Note though that if you want something more human readable, you would need to parse myStyle.properties and do as you like.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

wow, thank you @Loic.Aigon !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

LATEST

Hi @Karthik SG , From your capture it looks like you want to get the properties that have been changed from the Based On style. You can use reflect to get a list of properties and values of the style and its Based On style, then compare. This makes a new object containing the changed properties, and also creates a property:value string list

 

 

var ps = app.activeDocument.paragraphStyles.itemByName("Your Style Name");
var bo = app.activeDocument.paragraphStyles.itemByName(ps.basedOn.name);

var psp = ps.reflect.properties;
var bop = bo.reflect.properties;
var o = new Object();
var s = ""

var pn
for (var i = 0; i < bop.length; i++){
    try {
        if (ps[psp[i]] != bo[bop[i]]) {
           s += psp[i].name + " :" + ps[psp[i]] + "\r"
            o[psp[i].name] = ps[psp[i]]
        }
    }catch(e) {}  
}; 

$.writeln(s)
//returns a list of properties that have been changed from the based on style

$.writeln(o.name)
//returns the new object’s name property

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines