Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all 12845 articles
Browse latest View live

Change Ruler units of the document

$
0
0

Hi,

 

How to change the ruler units or measurement units of illustrator document using script?

 

I want to change the ruler/measurement units of activeDocument to type points

 

pls help


Rotation Point from Symbol Item

What is the best way to compare 2 arrays?

$
0
0

I am filtering through a lot of text frames to get some numbers. The numbers reside on 2 different layers.

 

So I have gathered just the numbers from each layer and given them each their own array.

 

I would like to compare the 2 arrays and if something is missing from either array have a text frame created under the correct header as a list of what is missing from each array (if any is missing at all).

 

So compare the sorted arrays....

tableCallouts to graphicCallouts

 

Any thoughts on the best method of doing this? There could also be duplicates in either list to throw another wrench into things

 

#target illustrator-22
var doc = app.activeDocument;


/* --------- Text filtering for the Tables layer --------- */
var tableText = doc.layers['Tables'].textFrames;


// Setup array to take data from loop
var tableCallouts = [];


// Loop to only find callout numbers
for (var i = 0; i < tableText.length; i++) {    var checkNumber = parseInt(tableText[i].contents);    if (isNaN(checkNumber) == false) {        //alert("Found a number " + tableText[i].contents);        tableCallouts.push(tableText[i].contents);    }
}


// Sort the array
tableCallouts.sort();


/* --------- Text filtering for the Callouts/CONNs layer --------- */
var graphicText = doc.layers['Callouts/CONNs'].textFrames;


// Setup array to take data from loop
var graphicCallouts = [];


// Loop to only find callout numbers
for (var i = 0; i < graphicText.length; i++) {    var checkNumber = parseInt(graphicText[i].contents);    if (isNaN(checkNumber) == false) {        graphicCallouts.push(graphicText[i].contents);    }
}


// Sort the array
graphicCallouts.sort();


var origin = doc.rulerOrigin
var graphicHeaderText = doc.textFrames.add();
graphicHeaderText.textRange.characterAttributes.textFont = app.textFonts.getByName("ArialMT");
graphicHeaderText.position = [-500, 0];
graphicHeaderText.contents = "MISSING FROM GRAPHICS"


var tableHeaderText = doc.textFrames.add();
tableHeaderText.textRange.characterAttributes.textFont = app.textFonts.getByName("ArialMT");
tableHeaderText.position = [-300, 0];
tableHeaderText.contents = "MISSING FROM TABLE"

Reading text from another open document tab/window and placing a grouped object in the current document for Adobe Illustrator

$
0
0

Hi,

 

So I would as the title suggest read information from another open document/tab

 

So if i have art boards with constant similar names it does a close match to an object and if found select copy it and paste on the art board with that name.

 

I hope this GIF makes sense of what I would like to accomplish. If you cannot see what is happening just right click and open image in new tab

 

 

 

Reading from another tab.gif

 

Thank you!

Script for making an object the artboard size.

$
0
0

I am looking for some help on trying to make an object the exact size of the artboard.  This is something I do on a daily basis for several different reasons and it would be very helpful if this can happen automatically for whatever size the artboard may be.  As I understand it the only way is with a script but I have no experience with making illustrator scripts, im definately no programmer.  I have set up quickkeys in the past to copy from the artboard inputs when you are on the artboard tool but these round to the nearest .01 and this is not accurate enough for what I am working with.  Also if I do this with multiple pages open illustrator is very slow to respond to the artboard tool.  If anyone has any idea where to start or has seen other such scripts I would greatly appreciate it.  Thank you.

 

Below is a script that I saw on here that I believe may contain what I need but now knowing programming I have no idea where to start on editing.  All I need is the part where an object is placed on the artboard that is the exact same size as the artboard.  If anyone can advise on editing I would greatly apprecaite it.

 

#target illustrator

function main() {
     if (app.documents.length == 0) {
          alert('Open a document before running this script');
          return; // Stop script here no doc open…
     }else{
          var docRef = app.activeDocument;
          with (docRef) {
               if (selection.length == 0) {
                    alert('No items are selected…');
                    return; // Stop script here with no selection…
               }
               if (selection.length > 1) {
                    alert('Too many items are selected…');
                    return; // Stop script here with selection Array…
               }else{                   
                    var selVB = selection[0].visibleBounds;
                    var rectTop = selVB[1] + 36;
                    var rectLeft = selVB[0] - 36;
                    var rectWidth = (selVB[2] - selVB[0]) + 72;
                    var rectHeight = (selVB[1] - selVB[3]) + 72;              
                    selection[0].parent.name = 'CC';
                    selection[0].filled = false;
                    selection[0].stroked = true;
                    var ccColor = cmykColor(0, 100, 0, 0);              
                    var ccCol = spots.add()
                    ccCol.name = 'CC';
                    ccCol.color = ccColor;
                    ccCol.tint = 100;
                    ccCol.colorType = ColorModel.SPOT;
                    var cc = new SpotColor();
                    cc.spot = ccCol;                   
                    selection[0].strokeColor = cc;
                    selection[0].strokeWidth = 1;                   
                    var tcLayer = layers.add();
                    tcLayer.name = 'TC';
                    var padBox = pathItems.rectangle(rectTop, rectLeft, rectWidth, rectHeight, false);
                    padBox.stroked = false;
                    padBox.filled = true;
                    var tcColor = cmykColor(0, 100, 90, 0);         
                    var tcCol = spots.add()
                    tcCol.name = 'TC';
                    tcCol.color = tcColor;
                    tcCol.tint = 100;
                    tcCol.colorType = ColorModel.SPOT;
                    var tc = new SpotColor();
                    tc.spot = tcCol;
                    padBox.fillColor = tc;    
                    padBox.move(docRef, ElementPlacement.PLACEATEND);
                    artboards[0].artboardRect = (padBox.visibleBounds);
                    redraw();
                    rectWidth = (rectWidth-72)/72;
                    rectWidth = roundToDP(rectWidth,1);
                    rectHeight = (rectHeight-72)/72;
                    rectHeight = roundToDP(rectHeight,1);
                    var textString = rectWidth + ' x ' + rectHeight;
                    prompt('Copy Me', textString);
               }         
          }
     }
}

main();

function roundToDP(nbr, dP) {
     dpNbr = Math.round(nbr*Math.pow(10,dP))/Math.pow(10,dP);
     return dpNbr;
}

function cmykColor(c, m, y, k) {
     var newCMYK = new CMYKColor();
     newCMYK.cyan = c;
     newCMYK.magenta = m;
     newCMYK.yellow = y;
     newCMYK.black = k;
     return newCMYK;
}

(JS) Checking if a folder exists

$
0
0

Hi everyone!

 

I would like to check if a folder exist. I was trying with this code but doesn't work.

I will thank you in advanced if you know a better way to do this.

 

Best regards_

 

- Code not working

path = Folder.desktop + "/MyFiles";
var folder = new Folder(path);
if(!folder.exists){  alert("Folder doesn't exists");
}else{   alert("Folder Exist");
}

How do I include DOM references to other apps in the same .jsx without returning failure?

$
0
0

Hey guys, say I have a single panel I want to use for both Illustrator and Photoshop. In JavaScript I can use csInterface to find the host application then route through a conditional to do app-specific actions, I figured I could just evalScript to different app-specific functions in doing so -- but I've noticed that having separate DOM references within my .jsx will cause the entire .jsx to fail. If I have a script that works perfectly in Photoshop but add something like app.isFill() anywhere in that .jsx, it returns Extendscript Fail -- even if I don't initiate it on auto-execute and try to put it in a conditional like `if (app.name === 'Adobe Illustrator'){alert (app.isFill());};`.

 

Is there a way to sneak cross-application DOM references in the same script? If not, then what would I need to do here?

an Illustrator error occurred: 1346458189 ('PARM')

$
0
0

Hello everyone,

 

I am trying to open some documents in Illustrator CS4 by javascript, walk through all layers including sublayers, doing something (for now just reading the layernames and showing them at an alert), closing the document and continue with the next document in the given folder until all documents in that folder are done.

 

By doing so I found an error I never have seen so far and I cant figure out where it comes from exactly to get rid of it.

The Error an Illustrator error occurred: 1346458189 ('PARM') appears randomly when cycling through the layers of the document but only every second document, so I guess there might be something wrong with closing a document and realeasing all references but I could not figure out what.

 

Maybe someone got an idea on this problem? Posting my sourcecode (just a simple test-code) below.

 

 

#target illustrator

 

var sourceFolderPath = "/e/TestAI";

var destinationFolderPath = "/e/TestZielverzeichnis";

var fileNameDefinition = "*.ai";

var sourceFolder = new Folder(sourceFolderPath);

var destinationFolder = new Folder(destinationFolderPath);

 

runCheckTool();

 

function runCheckTool() {

var contentInput = sourceFolder.getFiles(fileNameDefinition);

var fileRef;

var docRef;

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

fileRef = null;

docRef = null;

try {

fileRef = new File(contentInput[i]);

docRef = open(fileRef);

} catch(e) {

alert("# 1: " + e);

}

 

try{

checkLayers(docRef.layers);

} catch(e) {

alert("# 2: " + i + " " + e);

}

 

try {

docRef.close(SaveOptions.DONOTSAVECHANGES);

alert("end file index: " + i);

} catch(e) {

alert("#3: " + e);

}

}

}

 

function checkLayers(layerRef) {

var countLayers = layerRef.length;

for (var j = countLayers - 1; j >= 0; j--) {

if(layerRef[j].layers.length > 0) {

checkLayers(layerRef[j].layers);

}

alert ("Layer: " + layerRef[j].name);

}

}

 

 

Screenshot001.png


Export file as a DXF

$
0
0

My script is working nice until I try to export my document. I am trying to export my document as a DXF file.  Using the Illustrator CS6 Scripting Reference I am using the TIFF export as a reference as there are no examples for exporting as a DXF (my luck!).  This is what I have in VBscript.  With this script I get the following error on the second to last line:

 

"Illegal argument - argument 2 - Enumerated value expected"

 

As you can see I do have one: "0" so I suspect the error lies elsewhere in the code?  I'll take a JavaScript example if you are not into VBscript since the two look very similar and I think I can adapt it.

 

Set App = CreateObject("Illustrator.Application")

Set FSO = CreateObject("Scripting.FileSystemObject")

 

Dim dest

dest = "S:\SOCAL\Section_32\Veg DXFs LC\SOCAL_CK67_pineLC"

 

Set DXFexport = CreateObject("Illustrator.ExportOptionsAutoCAD")

    If App.Documents.Count > 0 Then

        Set docRef = App.ActiveDocument

        Call docRef.Export (dest, 0, DXFexport)      ' 0 = aiDXF

    End If

Creating Multi-Page PDF from a Layerd Illustrator file (script)

$
0
0

Often times when designing a logo I create different versions and variable options on layers. This can result in several layers in one Illustrator file. Is there an easy way or an existing script that will allow me to (with one click) create a multi-page PDF consisting of all the layers within my .ai file? The current method is turning on each layer, performing a save-as (PDF), then turning off said layer and turning on the next layer and repeating the task and so-on-and-so-forth, etc … It becomes tedious and quite often I save over the previous version, forgetting to re-name it or forget to perform a save on a certain layer. Can anyone help with some advice? I have never written my own script before but am not opposed to trying, where do I begin?

Any help is appreciated.

How to delete specific layers?

$
0
0

Hi,

 

I have a large batch of files (100+) that all have the same layer structure. The top layer is called 'Guides', the next layer is called 'Object", the next layer is called 'Shadow' and it goes on down through another 5 layers. I'd like to create a script that will select delete certain layers (eg. 'Guides') before I save out a new file as part of an action. I'm coming from a background in Photoshop, where this could all be done in actions, but appears you can't select layers in Illustrator (please correct me if I'm wrong!).

 

Any help in creating a script would be most appreciated!

 

Dave

Can you set a file to "self destruct" after a set period of time?

$
0
0

Hi!

 

I have someone interested in using a script that I had made. I would like to let them use it but I want to have some control over the period of time they are able to. My plan is to encrypt the script and hopefully set it to self destruct after a year, so they need a new file from me to continue using it. This way, if we stop doing business they can no longer use the script.

 

Is there a simple way to do something like this?

 

Thanks!

Change spot color and move to specific layer

$
0
0

I am new with scripting in Illustrator but see a need to script some repetitive tasks.

I start with a document that has most art on Layer 15 colored with various spot colors

I need to select all strokes of a specific color, change it to another color and move it to a different sub layer.

 

Layer 15

     all art

Template layer

     Cut

     Bleed

     Score

 

Can someone please get me started with the commands? I picked up on others who were moving items to different layers, but not changing colors also.

How to pixelate clipped placed items.

$
0
0

Hello,

 

I'm currently working on a script project and i'm stuck onto something. I need to embed all images (placed item (link)) but sometime, some of them are associated with a clipping mask. I know how to embed images but it seems different with clipping masks. What the staff usually do is :

 

- Select image

- Object menu > Pixelate

Done

 

I'm supposed to automate this process.

 

Can someone help me please ? I'm not able to find anything about the pixelate feature or anything alike.

Ai Packaging Script

$
0
0

Ok.. I'm sure this has been posted before (already searched, didn't find however), but does a file packaging script exist for AI? (one that collects all linked images and fonts and places them in one place) This would be IMMENSELY helpful to me if anyone can post a link to one or even be willing to write it.

 

OS: W7

AI Version: CS5

 

Thanks in advance!


transform fibonacci sequence script to add scaling

$
0
0

Hello,

 

I found this great script for taking an object and creating a fibonacci sequence (sunflower pattern).. it works great.

 

But you may notice that sunflower get bigger as they move from the inside out, so I would like to adjust the script to accommodate that.

 

here is the original script that works perfect for making the pattern.

 

var docSel=app.activeDocument;

var docSelSel=app.activeDocument.selection[0];

 

for (var i=1; i<1200;i++)

{

        var r=10*Math.sqrt(i);

        var t=137.5*Math.PI/180*i;

          var newSel=docSelSel.duplicate(docSelSel);

        newSel.translate(r*Math.cos(t),r*Math.sin(t));

}

docSelSel.remove();

 

 

here is my failed attempt to create scaling

 

var docSel=app.activeDocument;

var docSelSel=app.activeDocument.selection[0];

 

for (var i=1; i<1200;i++)

{

        var r=10*Math.sqrt(i);

        var t=137.5*Math.PI/180*i;

  var f = ( 2 / newSel.width ) * 100;

        var newSel=docSelSel.duplicate(docSelSel);

        newSel.translate(r*Math.cos(t),r*Math.sin(t));

  newSel.resize( f,f,true,true,true,true,f,Transformation.DOCUMENTORIGIN );

      

}

docSelSel.remove();

How do you write a loop for a function that runs an Action Script on one individual item completely before re-running the loop on the next item in the selection?

$
0
0

---------------------------------------------------

Adobe Illustrator CC 2018 Javascript

---------------------------------------------------

 

Hi everyone,

 

I'm trying to write a script that involves creating an action and running it on each item within a selection, but I haven't been able to get the action script to run on each item individually in order, rather than having it all happen at the same time.

 

I understand how to loop through all selected items for the native built-in Illustrator functions like selected[i].textRange.characterAttributes.size = fontSize; but I'm unclear on how to loop custom functions to run on each individual item of the selection completely before moving onto the next selected item.

 

---------------------------------------------------

MAIN BLOCK OF EXAMPLE CODE HERE:

---------------------------------------------------

 

function runActionScript(){     // code for Action Script goes here.
}
for( var i = 0; i < selected.length; i++ ){     runActionScript( selected[i] );     $.sleep(1000);     app.redraw();
}

 

 

Hopefully, that's enough information to see what I did wrong and how we can fix it. I'm sure I'm making a very simple rookie mistake with how I'm writing the loop to run on each individual item of the selection.

 

I've seen some mentions on other posts within the forums about using $.sleep(1000) and app.redraw(); to create a pause in the script, but it didn't seem to work for me.

 

---------------------------------------------------

MORE DETAILS BELOW:

---------------------------------------------------

 

What's happening is that the part of the action script involves:

  • Outlining the selected text
  • Labeling the selected text with an attribute note: "selectToMerge"
  • Duplicating the selected item
  • Moving the duplicated item
  • Selecting all objects with the "selectToMerge" note
  • Merging all "selectToMerge" items.

 

So it needs to run the script on each item in the selection completely before running it on the next item. Right now it seems to run the script on all of the items either together or separately but at the exact same time—either way, it causes everything to merge into one object, instead of having separate merged shapes. Hope that makes sense:

 

example-800px.jpg

 

The actual script I'm working on is a lot more complex with many other unrelated steps involved, but if the block of code above isn't enough, I have a more extended (but still simplified) example code below that focuses just on the part that creates the action and tries to run the action script for each selected item.

 

WARNING: Since the loop I wrote doesn't work properly, there are some errors when it runs. It basically re-runs multiple times based on the number of items you select. So if you decide to try and run this script as is for yourself, select only two or three live text frames to test, and just click "Continue" / "Stop" until it's done. Also, it's meant to be run on live text frames:

 

#target Illustrator


// If a document is open, start the script:
if( app.activeDocument ){


// FIRST, DEFINE VARIABLES & FUNCTIONS //////////////////////////////////////////////////    var doc = app.activeDocument;    var selected = doc.selection;    // Create Temporary Action to Load and Unload        // Based on example script written by Adobe Forums User: et3d    // Date: August 11, 2017    // URL: https://forums.adobe.com/message/9760856     // Which was based on:    // "Creating a dynamic action to use with app.doScript() method." guide written by Adobe Forums User: Silly-V    // Date: February 10, 2017    // URL: https://forums.adobe.com/message/9323811    // Many, many thanks to both Silly-V & et3d for sharing the immensely helpful information.    function createAction ( actionString, set ) {                var fpath = Folder ( "~/Desktop/" )        var f = File ( fpath + set + '.aia' );                f.open( 'w' );        f.write( actionString );        f.close();        app.loadAction( f );        f.remove();     }    function runActionScript(){        var set = 'Example Set';          var action = 'outlineDupMoveMerge';                var actionString = [                "/version 3",        "/name [ 11",        "   4578616d706c6520536574",        "]",        "/isOpen 1",        "/actionCount 1",        "/action-1 {",        "   /name [ 19",        "       6f75746c696e654475704d6f76654d65726765",        "   ]",        "   /keyIndex 0",        "   /colorIndex 0",        "   /isOpen 1",        "   /eventCount 7",        "   /event-1 {",        "       /useRulersIn1stQuadrant 0",        "       /internalName (adobe_createOutline)",        "       /localizedName [ 15",        "           437265617465204f75746c696e6573",        "       ]",        "       /isOpen 0",        "       /isOn 1",        "       /hasDialog 0",        "       /parameterCount 0",        "   }",        "   /event-2 {",        "       /useRulersIn1stQuadrant 0",        "       /internalName (adobe_attributePalette)",        "       /localizedName [ 17",        "           4174747269627574652053657474696e67",        "       ]",        "       /isOpen 0",        "       /isOn 1",        "       /hasDialog 0",        "       /parameterCount 1",        "       /parameter-1 {",        "           /key 1852798053",        "           /showInPalette 4294967295",        "           /type (ustring)",        "           /value [ 13",        "               73656c656374546f4d65726765",        "           ]",        "       }",        "   }",        "   /event-3 {",        "       /useRulersIn1stQuadrant 0",        "       /internalName (adobe_move)",        "       /localizedName [ 4",        "           4d6f7665",        "       ]",        "       /isOpen 0",        "       /isOn 1",        "       /hasDialog 1",        "       /showDialog 0",        "       /parameterCount 3",        "       /parameter-1 {",        "           /key 1752136302",        "           /showInPalette 4294967295",        "           /type (unit real)",        "           /value 0.0",        "           /unit 592476268",        "       }",        "       /parameter-2 {",        "           /key 1987339116",        "           /showInPalette 4294967295",        "           /type (unit real)",        "           /value -0.0",        "           /unit 592476268",        "       }",        "       /parameter-3 {",        "           /key 1668247673",        "           /showInPalette 4294967295",        "           /type (boolean)",        "           /value 1",        "       }",        "   }",        "   /event-4 {",        "       /useRulersIn1stQuadrant 0",        "       /internalName (adobe_sendBackward)",        "       /localizedName [ 13",        "           53656e64204261636b77617264",        "       ]",        "       /isOpen 0",        "       /isOn 1",        "       /hasDialog 0",        "       /parameterCount 0",        "   }",        "   /event-5 {",        "       /useRulersIn1stQuadrant 0",        "       /internalName (adobe_move)",        "       /localizedName [ 4",        "           4d6f7665",        "       ]",        "       /isOpen 0",        "       /isOn 1",        "       /hasDialog 1",        "       /showDialog 0",        "       /parameterCount 3",        "       /parameter-1 {",        "           /key 1752136302",        "           /showInPalette 4294967295",        "           /type (unit real)",        "           /value -21.2132034342",        "           /unit 592476268",        "       }",        "       /parameter-2 {",        "           /key 1987339116",        "           /showInPalette 4294967295",        "           /type (unit real)",        "           /value -21.213203437",        "           /unit 592476268",        "       }",        "       /parameter-3 {",        "           /key 1668247673",        "           /showInPalette 4294967295",        "           /type (boolean)",        "           /value 0",        "       }",        "   }",        "   /event-6 {",        "       /useRulersIn1stQuadrant 0",        "       /internalName (adobe_setSelection)",        "       /localizedName [ 13",        "           5365742053656c656374696f6e",        "       ]",        "       /isOpen 0",        "       /isOn 1",        "       /hasDialog 0",        "       /parameterCount 3",        "       /parameter-1 {",        "           /key 1952807028",        "           /showInPalette 4294967295",        "           /type (ustring)",        "           /value [ 13",        "               73656c656374546f4d65726765",        "           ]",        "       }",        "       /parameter-2 {",        "           /key 2003792484",        "           /showInPalette 4294967295",        "           /type (boolean)",        "           /value 0",        "       }",        "       /parameter-3 {",        "           /key 1667330917",        "           /showInPalette 4294967295",        "           /type (boolean)",        "           /value 1",        "       }",        "   }",        "   /event-7 {",        "       /useRulersIn1stQuadrant 0",        "       /internalName (ai_plugin_pathfinder)",        "       /localizedName [ 10",        "           5061746866696e646572",        "       ]",        "       /isOpen 0",        "       /isOn 1",        "       /hasDialog 0",        "       /parameterCount 1",        "       /parameter-1 {",        "           /key 1851878757",        "           /showInPalette 4294967295",        "           /type (enumerated)",        "           /name [ 3",        "               416464",        "           ]",        "           /value 0",        "       }",        "   }",        "}"        ].join( "\n" );        createAction( actionString, set );        app.doScript( action, set );        app.unloadAction( set, "" );    }


// THEN, START SCRIPT ////////////////////////////////////////////////////////////


    // If something is selected, run the script:    if( selected.length > 0 ){                for( var i = 0; i < selected.length; i++ ){            // If all selected items are text frames, run the action script:            if ( selected[i].typename === "TextFrame" ){                runActionScript( selected[i] );                $.sleep(1000);                app.redraw();               }            // If one or more of the selected selected items is not a text frame, display message:            else{                alert( "One or more of the selected items is not a text frame. Please select a text frame and try again." );            }                }    }    // If nothing selected, display message:    else{        alert( "Nothing is selected. Please select a text frame and try again." );    }

}
// If no document is open, display message:
else{
    alert( "No document found. C'mon man, get it together." );
}

Advanced "Save as PDF" script that saves 2 PDF presets with 2 different names.

$
0
0

Hi Everyone,

 

I am looking to improve a save as pdf workflow and was hoping to get some direction. Here is the background...

 

I routinely have to save numerous files as 2 separate PDFs with different settings (a high res printable version and a low res email version). Each file has to be renamed as follows...

 

Original filename = MikesPDF.ai

High Res PDF Filename = MikesPDF_HR.pdf

Low Res PDF Filename = MikesPDF_LR.pdf

 

I was able to alter the default "SaveAsPDF" script to save the files to my desired settings and to add the suffix to the name. So with these scripts here is how the workflow operates...

 

1. Open all files I wish to save as pdfs

2. Select script to save files as high res pdfs

3. Illustrator asks me to choose a destination.

4. Illustrator adds the appropriate suffix and saves each file as a pdf to my desired setting. ("Save As" not "Save a Copy").

5. Now all of the open windows are the new pdfs, not the original ai files.

6. Now I have to close each window. For some reason Illustrator asks me if I want to save each document when I tell it to close window, even though the file was just saved. I tell it to not save and everything seems to be fine.

7. Reopen all the files I just saved as high res pdfs.

8. Repeat the entire process except I run the script specifically designed for the low res pdfs.

 

What I would like to do is to combine these two processes so that there will be one script that saves both pdfs. From what I understand, the script can't support "Save A Copy" so the workflow would go as follows...

 

1. Open all files I wish to save as pdfs

2. Select single script to save files as both high res and low res pdfs

3. Illustrator asks me to choose a destination.

4. Illustrator saves each file as a High Res PDF and adds the the "_HR" suffix.

5. Illustrator then re-saves the open windows as a Low Res PDF and replaces the "_HR" suffix with "_LR".

 

Here is the code for the High Res script, The Low Res script is pretty much the same except for a different preset name and different suffix. Any pointer that anyone could give me would be most appreciated. I am pretty much a noob to this stuff so please keep that in mind.

 

Thanks!

Mike

 

---------------------------CODE----------------------------

 

/** Saves every document open in Illustrator

  as a PDF file in a user specified folder.

*/

 

 

// Main Code [Execution of script begins here]

 

 

try {

  // uncomment to suppress Illustrator warning dialogs

  // app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

 

  if (app.documents.length > 0 ) {

 

 

  // Get the folder to save the files into

  var destFolder = null;

  destFolder = Folder.selectDialog( 'Select folder for PDF files.', '~' );

 

 

  if (destFolder != null) {

  var options, i, sourceDoc, targetFile;

 

  // Get the PDF options to be used

  options = this.getOptions();

  // You can tune these by changing the code in the getOptions() function.

 

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

  sourceDoc = app.documents[i]; // returns the document object

 

  // Get the file to save the document as pdf into

  targetFile = this.getTargetFile(sourceDoc.name, '.pdf', destFolder);

 

  // Save as pdf

  sourceDoc.saveAs( targetFile, options );

  }

  alert( 'Documents saved as PDF' );

  }

  }

  else{

  throw new Error('There are no document open!');

  }

}

catch(e) {

  alert( e.message, "Script Alert", true);

}

 

 

/** Returns the options to be used for the generated files. --------------------CHANGE PDF PRESET BELOW, var NamePreset = ----------------

  @return PDFSaveOptions object

*/

function getOptions()

{var NamePreset = 'Proof High Res PDF';

  // Create the required options object

  var options = new PDFSaveOptions();

     options.pDFPreset="High Res PDF";

  // See PDFSaveOptions in the JavaScript Reference for available options

 

  // Set the options you want below:

 

 

  // For example, uncomment to set the compatibility of the generated pdf to Acrobat 7 (PDF 1.6)

  // options.compatibility = PDFCompatibility.ACROBAT7;

 

  // For example, uncomment to view the pdfs in Acrobat after conversion

  // options.viewAfterSaving = true;

 

  return options;

}

 

 

/** Returns the file to save or export the document into.----------------CHANGE FILE SUFFIX ON LINE BELOW, var newName = ------------------

  @param docName the name of the document

  @param ext the extension the file extension to be applied

  @param destFolder the output folder

  @return File object

*/

function getTargetFile(docName, ext, destFolder) {

  var newName = "_HR";

 

 

  // if name has no dot (and hence no extension),

  // just append the extension

  if (docName.indexOf('.') < 0) {

  newName = docName + ext;

  } else {

  var dot = docName.lastIndexOf('.');

  newName = docName.substring(0, dot)+newName;

  newName += ext;

  }

 

  // Create the file object to save to

  var myFile = new File( destFolder + '/' + newName );

 

  // Preflight access rights

  if (myFile.open("w")) {

  myFile.close();

  }

  else {

  throw new Error('Access is denied');

  }

  return myFile;

}

Retrieve whats in the clipboard possible?

$
0
0

Is it possible to retrieve whats in the clipboard through a script?

If so how?

Resolution check in illustrator

$
0
0

How to check the raster image resolution in illustrator through script?

Viewing all 12845 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>