Skip to main content
neoguy32
Known Participant
June 19, 2019
Question

Setting stroke to overprint

  • June 19, 2019
  • 3 replies
  • 883 views

I have a script that puts a border around a page, it currently sets the weight of the strokes to a Pantone Colour I choose but I would like to change the script. .js to get the stroke to overprint.

Any ideas?

I am not a scripting guy so be gentle.

This topic has been closed for replies.

3 replies

neoguy32
neoguy32Author
Known Participant
June 24, 2019

Here is the script it works but I can get the stroke to over print.

#targetengine 'pageborder127'

var    scriptName = "Cutter ",

    scriptVersion = "1.27",

    layerName = scriptName + "Layer";

var    alignStrings = ['Inside','Outside','Center'],

    ptBorder = ptBorder||.5,                        // default border weight (pts)

    pgMode = pgMode||1,                                // -1=active page | 1=all pages

    align = align||0,                                // default alignment index

    jDots = jDots||0,                                // Japanese dots flag,

    jDotsStyleName = false,

    solidStyleName = false;

var createBorder = function(/*Layer*/layer)

//------------------------------------------------

// this: Page [collective allowed]

{

    var pages = this.getElements(),

        alignMode = StrokeAlignment[alignStrings[align].toLowerCase()+'Alignment'],

        pg;

   

    var recProps = {

        fillColor: 'None',

        strokeColor: 'PANTONE Cool Gray 5 C',

        strokeTint: 100,

        strokeWeight: ptBorder,

        strokeAlignment: alignMode,

        strokeType: (jDots && jDotsStyleName) || solidStyleName,

        // [fix101125]

        textWrapPreferences: (parseInt(app.version) > 5) ? // [fix101202]

            {textWrapMode: TextWrapModes.NONE} :

            {textWrapType: TextWrapTypes.NONE}

        };

    while( pg=pages.pop() )

        {

        recProps.geometricBounds = pg.bounds;

        pg.rectangles.add(layer,undefined,undefined,recProps);

        }

};

var pageBorderMain = function()

//------------------------------------------------

{

    var doc = app.documents.length&&app.activeDocument;

   

    if( !doc ) throw Error("Please open a document before running " + scriptName + ".");

   

    var vwPrefs = doc.viewPreferences,

        strokeUnits = ('strokeMeasurementUnits' in vwPrefs)?

            vwPrefs.strokeMeasurementUnits:

            MeasurementUnits.points;

    jDotsStyleName = (function()

        {

        try{return doc.strokeStyles.itemByName("$ID/Japanese Dots").name;}

        catch(_){}

        return false;

        })();

    solidStyleName = (function()

        {

        try{return doc.strokeStyles.itemByName("$ID/Solid").name;}

        catch(_){}

        return false;

        })();

    if( !solidStyleName ) throw Error("Unable to find the 'Solid' stroke style in InDesign!");

   

    var canRemove = (function()

        {

        var r = false;

        try{r=!!doc.layers.itemByName(layerName).id;}

        catch(_){}

        return r;

        })();

   

    var dlgRet = (function()

        {

        var dlgTitle = ' ' + scriptName + ' ' + scriptVersion + "  |  \u00A9Indiscripts.com",

            d = app.dialogs.add({name:dlgTitle, canCancel:true}),

           

            pn = d.dialogColumns.add().borderPanels.add(),

            dc = pn.dialogColumns.add(),

            dr = dc.dialogRows.add(),

           

            // Weight

            sWeight = dr.dialogColumns.add().

                staticTexts.add({

                staticLabel: "Weight:",

                minWidth: 80,

                }),

            meWeight = dr.dialogColumns.add().

                measurementEditboxes.add({

                editValue: ptBorder,

                editUnits: strokeUnits,

                minimumValue: .1,

                maximumValue: 5,

                smallNudge: .25,

                largeNudge: .1,

                }),

           

            // Alignment

            sAlign = (dr=dc.dialogRows.add()).dialogColumns.add().

                staticTexts.add({

                staticLabel: "Alignment:",

                minWidth: 80,

                }),

            ddAlign = dr.dialogColumns.add().

                dropdowns.add({

                stringList: alignStrings,

                selectedIndex: align,

                }),

           

            // All Pages flag

            cbAllPages = (dc=pn.dialogColumns.add()).dialogRows.add().dialogColumns.add().

                checkboxControls.add({

                staticLabel: "All Pages",

                checkedState: pgMode==1,

                }),

               

            // Dots flag

            cbDots = jDotsStyleName?

                (dr=dc.dialogRows.add()).dialogColumns.add().

                checkboxControls.add({

                staticLabel: "Dotted Stroke",

                checkedState: !!jDots,

                }):

                {checkedState:false},

           

            // Remove

            cbRemove = canRemove?

                d.dialogColumns.add().

                checkboxControls.add({

                staticLabel: "Remove the border",

                checkedState: false,

                }):

                {checkedState:false};

       

        var ret = d.show()&&{

            ptBorder: meWeight.editValue,

            align: ddAlign.selectedIndex,

            pgMode: (cbAllPages.checkedState)?1:-1,

            jDots: !!cbDots.checkedState,

            removeBorder: cbRemove.checkedState,

            }

        d.destroy();

        return ret;

        })();

   

    if( !dlgRet ) return false;

    ptBorder = dlgRet.ptBorder;

    pgMode = dlgRet.pgMode;

    align = dlgRet.align;

    jDots = dlgRet.jDots;

   

    // [fix100914]

    var activeLayer = (function()

        {

        var al = doc.activeLayer;

        return ( al.name == layerName )?

            (doc.layers.length==1&&doc.layers.add()):

            al.getElements()[0];

        })();

    // [/fix100914]

   

   

    var removeBorder = dlgRet.removeBorder;

    var borderLayer = (function()

        {

        var layers = doc.layers;

        try{layers.itemByName(layerName).remove();}catch(_){};

        return ( removeBorder ) ? null :

            layers.add({name: layerName, printable: true}).

            move(LocationOptions.atBeginning); // [fix100916]

        })();

    if( removeBorder ) return;

   

    // [fix100914]

    var ro = vwPrefs.rulerOrigin;

    vwPrefs.rulerOrigin = RulerOrigin.spreadOrigin;

    // [/fix100914]

    // Main process

    createBorder.call(

        (pgMode==1)?doc.pages.everyItem():app.activeWindow.activePage,

        borderLayer

        );

   

    borderLayer.locked = true;

    // [fix100914]

    if( activeLayer ) doc.activeLayer = activeLayer;

    vwPrefs.rulerOrigin = ro;

    // [/fix100914]

};

app.scriptPreferences.enableRedraw = false;

try    {pageBorderMain();}catch(_){alert(_);}

app.scriptPreferences.enableRedraw = true;

Community Expert
June 24, 2019

Add the following line, under the line strokeType: (jDots && jDotsStyleName) || solidStyleName,

overprintStroke : true,

-Manan

-Manan
neoguy32
neoguy32Author
Known Participant
June 27, 2019

Fantastic mate!

neoguy32
neoguy32Author
Known Participant
June 20, 2019

I have tried getting hold of there person who I thought might have scripted it, but the details are vague. Will have to try myself.

Community Expert
June 20, 2019

Since you have not shared your script i can't point to the specific change you need to do, but you can set Overprint stroke by using the following

obj.overprintStroke = true

Where obj is the object for which you want to set the overprint stroke. In your code check for which object the stroke is being set and then add this line for that object as well, by changing obj to whatever the object is in your code.

In order to test this code you can select an object in InDesign and run the following, it will set the overprint stroke for the selected object

app.selection[0].overprintStroke = true

-Manan

-Manan
Community Expert
June 19, 2019

Hi,

Can't you ask the original author of the script to make the changes? That would be most appropriate to do, if you have the rights to make the changes to the script then share it across we can edit it

-Manan

-Manan