2 Replies Latest reply on Jan 29, 2015 10:39 AM by kcjoplin1982

    Is there a way to populate an InDesign document with Pantone colors from a .csv document?

    kcjoplin1982

      I have a CSV document that inputs copy information into various labels we have set up in InDesign, but we also have Pantone colors that we put into this document.  Currently, it just imports the color number and we manually change the color ourselves, but is there a way to automatically populate the colors into the document?

        • 1. Re: Is there a way to populate an InDesign document with Pantone colors from a .csv document?
          Loic.Aigon Adobe Community Professional

          Hi,

           

          Here is some code you may want to play with

           

          Array.prototype.contains =  function ( object )

          {

            var i = 0, n = this.length;

           

            for ( i = 0 ; i < n ; i++ )

            {

            if ( this[i] === object )

            {

            return true;

            }

            }

           

            return false;

          }

           

           

          function createLabels() {

           

            var filterFunction = function(file)

            {

            return /\.csv$/.test ( file.name );

            }

            var f = File.openDialog("Please select CSV Files…", filterFunction);

            var sep = "\t";

            var n = 0;

            var headers = [];

            var rows = [], row = [];

            var doc, m, pw,pb,ph, np, tf, tfo;

            var p;

            if ( !f) { return; }

           

            f.open("r");

            headers = f.readln().split(sep);

            while ( !f.eof ){

            row = f.readln().split(sep);

            row.length>1 && rows [ rows.length ]  = {contents:row[0], colorName:row[1]};

            }

           

            n = rows.length;

           

            if ( !n ) {

            alert("No data");

            return;

            }

           

           

            doc = app.documents.add();

            doc.documentPreferences.facingPages = false;

            m = doc.pages[0].marginPreferences;

            pb = doc.pages[0].bounds;

           

            while (n--) {

            row = rows[n];

            np = doc.pages.add();

            doc.importAdobeSwatchbookSpotColor ( row.colorName );

            tfo = {

            geometricBounds:[pb[0]+m.top, pb[1]+m.right, pb[2]-m.bottom, pb[3]-m.left],

            contents:row.contents,

            fillColor:doc.colors.itemByName ( row.colorName ),

            }

            tf = np.textFrames.add(tfo);

            }

           

           

            doc.pages[0].remove();

          }

           

          createLabels();

           

          Sorry for not using the highlighting code option but it wasn't displaying the whole stuff :\

           

          Loic

          http://www.ozalto.com

          • 2. Re: Is there a way to populate an InDesign document with Pantone colors from a .csv document?
            kcjoplin1982 Level 1

            Thanks so much Loic! I am still new to using scripts within InDesign. How would I go about getting this to function?