Skip to main content
dublove
Legend
Nov 23, 2026 8:31 AM UTC
Answered

How to import the "punctuation squeezing" and "head and tail avoidance" settings of CJK version?

Hello everyone.

If I had a 'punctuation squeeze' file placed in 'D: \ aa \ pu. indd',
Place a 'avoid head and tail' file in 'D: \ aa \ av. indd'
How can I import them using scripts.

This doesn't seem to be available in the English version, so there may be very little information about it.
 

 

    Peter Kahrel
    Peter KahrelCorrect answer
    Community Expert
    Nov 23, 2026 7:31 PM UTC

    If you want to load styles using a script, the Load Paragraph Style route won’t do you any good because a script can’t make a selection in the Load Styles window.

    You’ll have to take your source document, remove all the styles that you don’t want import in other documents,, save it as a copy, then use doc.importStyles() to import styles from that copy.

    10 replies

    Peter Kahrel
    Community Expert
    Peter KahrelCommunity ExpertCorrect answer
    Community Expert
    Nov 23, 2026 7:31 PM UTC

    If you want to load styles using a script, the Load Paragraph Style route won’t do you any good because a script can’t make a selection in the Load Styles window.

    You’ll have to take your source document, remove all the styles that you don’t want import in other documents,, save it as a copy, then use doc.importStyles() to import styles from that copy.

    Translate
    dublove
    dubloveAuthor
    Legend
    Nov 24, 2026 3:45 AM UTC

    Yes, using doc. importStyles() may be faster.
    But I seem to like the "Load Paragraph Styles..." dialog box that comes with the ID, which allows for selection, so I decided to use invoke(); Imitating the menu operation.
    But it's still a bit annoying, invoke(); You actually asked me to select two files

    Translate
    Peter Kahrel
    Community Expert
    Community Expert
    Nov 23, 2026 1:08 PM UTC

    In fact you don't need a script. Apply the properties in the styles in the CJK version, then in the English version, import the styles. Attributes that aren't exposed in the English version are imported anyway.

    Translate
    dublove
    dubloveAuthor
    Legend
    Nov 23, 2026 2:07 PM UTC

    ​@Peter Kahrel 

    You seem to have taught me a way to know the English name of a property before.
    I seem to have forgotten.
    I need to merge the script for importing 'punctuation squeezing' into my other import style script.
    But I don't know how to start.

    Ai found one, I haven't understood it yet

    //The name of the target punctuation squeeze set must be an existing name in the current document
    //Common built-in names: "Simplified Chinese default value", "Japanese default value", "None"
    Var targetKinsokuSetName="Simplified Chinese default value";
    function applyKinsokuToParagraphStyles() {
    var doc = app.activeDocument;
    if (!doc) {
    Alert ("Please open an InDesign document first");
    return;
    }
    //Check if the target squeeze set exists
    var kinsokuSetExists = false;
    for (var i = 0; i < doc.kinsokuSets.length; i++) {
    if (doc.kinsokuSets[i].name == targetKinsokuSetName) {
    kinsokuSetExists = true;
    break;
    }
    }
    if (!kinsokuSetExists) {
    Alert ("Error: There is no punctuation squeeze set named ''+targetKinsokSetName+'' in the document. \Please first create or import the collection in [Text]>[Punctuation Squeezing Settings]. ");
    return;
    }
    var paraStyles = doc.paragraphStyles;
    var count = 0;

    //Traverse all paragraph styles (skip [no paragraph styles])
    for (var i = 1; i < paraStyles.length; i++) {
    var style = paraStyles[i];
    try {
    //Apply punctuation squeezing set
    style.kinsokuSet = targetKinsokuSetName;
    //Optional: Simultaneously set the head and tail avoidance rule (Kinsoku Type)
    //Common values: KinsokuType.JIS_KINSOKU, KinsokuType.ChineSE_KINSOKU
    // style.kinsokuType = KinsokuType.CHINESE_KINSOKU;

    count++;
    } catch (e) {
    $. riteln ("style"+"style. name+" "application failed:"+e.message);
    }
    }

    Alert ("Completed! Update the punctuation squeezing settings for the "+count+" paragraph styles to "+targetKinsokuSetName";
    }
    app.doScript(applyKinsokuToParagraphStyles, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, " Apply punctuation squeezing set ");

     

    Translate
    Peter Kahrel
    Community Expert
    Community Expert
    Nov 23, 2026 10:32 AM UTC

    Those properties aren’t exposed in non-CJK interfaces, but they are exposed to scripting. So you can use a script to get those properties from one file and apply them in another file.

    Translate
    dublove
    dubloveAuthor
    Legend
    Nov 23, 2026 11:14 AM UTC

    Hi ​@Peter Kahrel 

    Can you give me a direction or find some information at www.indesignjs.de?

    Thank you very much.

    Translate