Skip to main content
max_fr76
Participant
January 4, 2016
Frage

batch able to ungroup PDF objects and change colors from RGB into CMYK with lookuptable

  • January 4, 2016
  • 1 Antwort
  • 503 Ansichten

Hi !

I am a beginner with AI but I know it's very powerful !

I have several RGB PDF files with grouped objects and I want to develop a script that :

-        is able to process several PDF files (e.g. all PDF in a folder)

-        ungroup the objects of each PDF file (I found the UngroupV1.js script on this forum, I want to combine it into my final script for batch process)

-        convert RGB PDF to CMYK PDF using a txt lookup table where I can set myself the values (I don't use a lot of colors but I have to get precise CMYK values)

I found this script (here) that "select all items in your original document, create a new CMYK document and paste it" :

    • #target illustrator
    • doc=activeDocument;
    • for (i=0; i<doc.layers.length; i++){doc.layers.hasSelectedArtwork=true;} // select all 
    • copy();// 
    • doc2=documents.add(DocumentColorSpace.CMYK,doc.width,doc.height,doc.artboards.length); // new doc CMYK 
    • doc2.rulerOrigin=doc.rulerOrigin; //  
    • doc2.pageOrigin=doc.pageOrigin; // 
    • paste(); // 
    • for (i=0; i<doc2.pageItems.length; i++){doc2.pageItems.position=doc.pageItems.position;} ; // restore position

And this one (found here) that I modified to round CMYK to the nearest 10 but I need to deal with adding the colors of my PDF in the swatches and I don’t find how to do it in JS…

    function roundColorValues(color) { 

              var col = color; 

              col.cyan = (Math.round((col.cyan)/10))*10; 

              col.magenta = (Math.round((col.magenta)/10))*10; 

              col.yellow = (Math.round((col.yellow)/10))*10; 

              col.black = (Math.round((col.black)/10))*10; 

    } 


     var idoc = app.activeDocument; 

    var sws = idoc.swatches; 

           

    for (i = 0; i<sws.length; i++) { 

              var sw = sws;

              if (sw.color.typename == "CMYKColor") 

                        roundColorValues (sw.color); 

              else if (sw.color.typename == "SpotColor") { 

//$.writeln(sw.color.spot.getInternalColor()); 

                        roundColorValues (sw.color.spot.color); 

//$.writeln(sw.color.spot.getInternalColor()); 

              }

    } 

I have difficulties to build script able to do all that stuff in once, somebody can help me ?

Thanks !

Max

Dieses Thema wurde für Antworten geschlossen.

1 Antwort

max_fr76
Participant
February 3, 2016

Nobody has some ideas to do what I dream to do with AI ?

Silly-V
Legend
February 3, 2016

First, start with a very simple script which encompasses only one of the most basic functions of your desired end goal. For example, create a function to get all of the files inside of a folder. Once that is working, you can make more and more functions which then can be used as components of your main script.