Resize method with Javascript in Illustrator CS4

var objectBounds = docRef.visibleBounds;
var W = objectBounds[2] - objectBounds[0]; //figures the width
var H = objectBounds[1] - objectBounds[3]; //figures the height
// W & H are reporting the size in points ... convert to picas
var picaW = W / 12;
var picaH = H / 12;
// do the math for the correct column width: settings / width = percentage in decimal; multiply by 100 to get the decimal place in the right spot.
var endWidth
var percentageX = Math.round((endWidth / picaW) * 100);
var percentageY = percentageX;
for (var a=0; a<docRef.layers.length; a++){
     var layerRef = docRef.layers[a];
     layerRef.hasSelectedArtwork=true;   // select all
     // now to resize based on the percentage
     layerRef.pageItem.resize(percentageX, percentageY);
The width and height are coming out fine. But in this last line, that resize is just not working. When I run it I get an error that says: undefined is not an object.
The syntax must be wrong ... any ideas?
Thanks in advance!

Great. Grouping was exactly what I needed to do. This works perfectly now (unless there are a few clipping masks already in the image, then it gets a little weird). Here's what I ended up with:
var objectBounds = docRef.visibleBounds;
var W = objectBounds[2] - objectBounds[0];    // figures the width
var H = objectBounds[1] - objectBounds[3];     // figures the height
// W & H are reporting the size in points ... convert to picas
var picaW = W / 12;
var picaH = H / 12;
// do the math for the correct column width: settings / width = percentage in decimal; multiply by 100 to get the decimal place in the right spot.
var endWidth = 20;
var percentageX = Math.round((endWidth / picaW) * 100);
var percentageY = percentageX;
// creates group on a new layer and omits guides
var theLayer = docRef.layers.add();
theLayer.move(docRef, ElementPlacement.PLACEATBEGINNING );
var theGroup = docRef.groupItems.add();
theGroup.name = "theGroup";
theGroup.move(theLayer, ElementPlacement.PLACEATBEGINNING );
for (var b = docRef.layers.length - 1; b > 0; b--) {
if (docRef.layers[b].visible == true) {
docRef.layers[b].locked = false;
// move the items into the group if they are not guides;
for (var a = docRef.layers[b].pageItems.length - 1; a >= 0; a--) {
if (docRef.layers[b].pageItems[a].guides != true) {
docRef.layers[b].pageItems[a].locked = false;
docRef.layers[b].pageItems[a].move(theGroup, ElementPlacement.PLACEATBEGINNING)
// now to resize based on the percentage
for (var s=0; s<docRef.groupItems.length; s++){
     docRef.groupItems[s].resize(percentageX, percentageY);
var newPicaW = (objectBounds[2] - objectBounds[0]) / 12;
var newPicaH = (objectBounds[1] - objectBounds[3])/ 12;

Similar Messages

  • Problem with reinstalling Adobe Illustrator CS4 on new pc

    Using a new PC with Windows 7.  Upon reinstalling and inputting serial number, prompt appears..."We looked inthe default locations for qualifying products installed on this machine but none found.  You may verify upgrade eligibility now by completing fields to the right."  Choices given do not include Adobe Illustrator CS4.  What next?  I appreciate the help.

    I have a disc in the same box  that says CS3.  I thought that was an older version.  Should I try installing that disc first?  It seems to have a different serial number. Thanks so much for your help.  I appreciate it. 
    Date: Mon, 3 Sep 2012 15:25:41 -0600
    From: [email protected]
    To: [email protected]
    Subject: problem with reinstalling Adobe Illustrator CS4 on new pc
        Re: problem with reinstalling Adobe Illustrator CS4 on new pc
        created by Jeff A Wright in Downloading, Installing, Setting Up - View the full discussion
    It is looking for the qualifying product which entitles you to use the Illustrator CS4 update.  Did you have an older version of Illustrator which upgraded from?
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4670448#4670448
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4670448#4670448. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Downloading, Installing, Setting Up by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Issues with eyedropper in illustrator CS4

    I've just moved onto Illustrator CS4,a nd ahve discovered several glitches with the eyedropper tool, in that you will try to sample a fill and stroke from another object, and it will show in the stroke and fill boxes that it has taken on this appearance, but the object itself doesn't change. Or sometimes it will take on the stroke, but not the fill. the only way i've gotten around this is to use the pathfinder tool to divide the object by itself, and then the eyedropper seems to work. major pain though.
    does anyone know if there is any way to stop this happening?
    thanks

    Check your graphics driver configuration and install a new one/ different one. Also check your color profiles, should you be using any. Since sampling is done at the preview level, there may simply be an issue here where it sometimes cannot correctly "see" what's beneath. Also of course look for invisible layers or visible layers with seemingly nothing on them. Some of them may have appearances applied that would "block" everything. Sometimes a drop shadow on a stray line or point can have the weirdest effects... Other than that I'm not aware of standing issues with this, but anything is possible.
    Mylenium

  • Guys ,i have encountered a problem with my adobe illustrator cs4

    i am using illustrator cs4.i have a problem with type along the path feature.i have made some changes to it which i dont remember.so now the text is appearing one below the other rather tha appearing one after the other.how do i reset the settings.plz help!!!!

    Hi teja1995,
    I suspect that you need to adjust the in and out points of the text on the path. Try watching this tutorial, "Putting type on a path," in the Illustrator CC Creative Cloud Learn show to learn how to do this successfully.
    Hope this helps!
    Best,
    Rita Amladi

  • Eyedropper tool with masks in Illustrator CS4

    When I sample a colour from a masked object in Illustrator CS4 it doesn't sample the colour correctly. It looks like it's doing it optically rather than using the exact colour breakdown I have assigned the colour. It doesn't even look like the same colour when I colour another object. It will often be slightly darker. Does anyone know if this is a bug or if there is some other reason it is happening. Never happened in any of the other versions.

    Yupp, as Scott said. Ugly annoyance.
    Mylenium

  • Problem with eps transparency, Illustrator CS4

    Hi!
    I truly hope you can help me with this because I really can't find the answer myself.
    I need to save eps-versions of the files I make in the Illustrator.
    I have made a script (using Javascript) to get the right settings for eps automatically and it has worked fine, but now that I upgraded to CS4 there's suddenly a problem. Script used to work so that any excess transparency around the image was cropped off. Now it remains there and causes problems later in the processes where these eps-files are used.
    If I look at the eps-files in the Photoshop I can see that the size of the artboard remains there as transparency.
    Here are the settings for saving eps in the script:
    function getEPSOptions()
    var epsSaveOpts = new EPSSaveOptions();
    epsSaveOpts.cmykPostscript = true;
    epsSaveOpts.embedAllFonts = true;
    epsSaveOpts.includeDocumentThumbnails = false;
    epsSaveOpts.preview = EPSPreview.None;
      return epsSaveOpts;
    I noticed that I can crop the transparency off with this line:
    saveDoc.cropBox = saveDoc.visibleBounds
    But the problem here is that if the size of the illustration is larger than artboard this will actually make the size of the eps-file bigger.
    I need a solution where the tranparency is cropped off, but the artboard area is never made larger by the script...
    Any ideas? Anyone?

    Heh ... I happened to write a function for exactly this just the other day. Not sure how this goes exactly with visible vs geometric bounds. Depending on exactly what you need, it might be problematic.
    myDoc = app.activeDocument;
    var docBounds = (function() {
    myDoc.LeftPoint = myDoc.pageItems[0].left;
    myDoc.RightPoint = myDoc.pageItems[0].left + myDoc.pageItems[0].width;
    myDoc.TopPoint = myDoc.pageItems[0].top;
    myDoc.BottomPoint = myDoc.pageItems[0].top - myDoc.pageItems[0].height;
    for (i=0;i<myDoc.pageItems.length-1;i++) {
    myDoc.LeftPoint = (myDoc.pageItems[i].left < myDoc.LeftPoint) ? myDoc.pageItems[i].left : myDoc.LeftPoint;
    myDoc.RightPoint = (myDoc.pageItems[i].left + myDoc.pageItems[i].width > myDoc.RightPoint) ? myDoc.pageItems[i].left + myDoc.pageItems[i].width : myDoc.RightPoint;
    myDoc.TopPoint = (myDoc.pageItems[i].top > myDoc.TopPoint) ? myDoc.pageItems[i].top : myDoc.TopPoint;
    myDoc.BottomPoint = (myDoc.pageItems[i].top - myDoc.pageItems[i].height < myDoc.BottomPoint) ? myDoc.pageItems[i].top - myDoc.pageItems[i].height : myDoc.BottomPoint;
    return [myDoc.LeftPoint,myDoc.TopPoint,myDoc.RightPoint,myDoc.BottomPoint]
    myDoc.artboards[0].artboardRect = docBounds;

  • Issues with save in Illustrator CS4

    When I try to save a file in Illustrator it takes ages for the "Illustrator Options" dialogue to appear, upwards of 30 seconds. During this time illustrator is frozen. I have tried saving a file with just a single line in it and all swatches brushes etc deleted and this still occurs so it is independent of file size and complexity. Also it happens regardless of the file type I am saving, eps ai etc.
    This also occurs when saving a file with the same name (Ctrl+S), it just takes ages and freezes Illustrator in the meantime, though obviously no dialogue box appears.
    Once the progress bar appears it seems to progress at the correct speed, it's just there's that initial long pause before saving commences.
    Files also open at the right speed.
    Saving different files in other programs e.g. psd files in Photoshop works fine, so I'm sure this is an Illustrator problem rather than a drive or hardware problem.
    I am running CS4 on a PC and have run updates recently. This problem just started occurring a day or two ago.
    Any help or pointers would be very much appreciated!

    ok i think I've got this sorted. I found the thread where someone was having a similar problem because of installing a new printer so changed my default printer to adobe pdf (even though I have had the same printer for years) and this solved the problem.
    A new conflict must have just started for some reason, perhaps something to do with switching to cable broadband and the new equipment related to that (?)

  • Call applet method with javascript

    my html - code:
    <APPLET NAME="Mail" ... ... ></APPLET>
    <form action="javascript:document.applets("Mail").test("Execute JAVA Applet Function")">
    <input type="submit" value="Execute Applet Function">
    </form>
    my applet code:
    public void test(String t)
    {System.out.println("executing test()");
    teststr = t;
    repaint();
    in the paint() method i draw the teststr with Graphics.drawString - but nothing happens...
    any suggestions?
    thx

    Directly calling a Java Applet's public method from within
    JavaScript is made possible by LiveConnect which is not implemented by Internet Explorer as of yet. LiveConnect is only available on Netscape navigator at this time.

  • Calling FP Methods with Javascript

    I'd like to be able to jump to specific pages in my
    flashpaper document using an html / javascript link. My javascript
    function setThePage gets a page number from the HTML link and feeds
    the value to the flash file (which my flashpaper movie clip loads
    into). That value is then dumped into a function that eventually
    sets the setThePage value equal to setCurrentPage, which is listed
    in the flashpaper API as the function that changes the current
    page. I've had no luck. I'm getting a javascript error telling me
    the object doesn't support the method or function and I think it
    has to do with the setCurrentPage function only working on the load
    of the flashpaper swf. Does anyone have a different solution for
    using html links to jump to specific flashpaper pages?

    Rich,
    I am interested in doing similar things from within a
    FlashPaper document loaded into my Flash movie. I wish to create
    links within the FlashPaper doc. that will talk to Actionscript in
    the main movie. I know that using the Flash 8 ExternalInterface
    Class is key, but in creating links in a Word Doc that eventually
    becomes FP, I haven't a clue. It's easy enough to create links that
    navigate to other URLs, or with the same page, but with the parent
    Flash movie...
    Anyway, if you have discovered anything, please share. I will
    also, should I discover anything. Thanks, Mike.
    mailto:[email protected]

  • Help to create outlines using javascript in adobe illustrator cs4

    Hi,
    Please help me to create outlines using javascript in illustrator cs4.
    Thanks
    Karthik

    The textFrame object has a createOutline() method. So if you are wanting to save a version of your file that will not require fonts then loop thru these items in your document… (Loop backwards btw its easier that way) Take a look at the other posts at the top here as others are wanting to do the same thing… If your document is more complex then you may need to iterate all the way though which takes a bit more work…

  • Broken Illustrator CS4 "Open With" File Association

    I want to open an SVG file, using Illustrator CS4. (I have the Design Premium Suite.) I cannot get it to open from Windows Explorer in CS4. Double-clicking the file opens it in CS3. Here's what I do and what happens:
    1. Right-click on the SVG file in Windows Explorer.
    2. Choose "Open With." A menu of programs pops up. Illustrator CS4 is not in the list, but CS3 is.
    3. So I click on "Choose Program" to find CS4. The "Open With" window opens.
    4. "Adobe Illustrator CS4" is not in the "Recommended Programs" list, but it is in the "Other Programs" list. However, I note that its listing has a generic icon, instead of the "Ai" CS4 icon.
    5. I click on "Adobe Illustrator CS4" expecting the program to load. Instead, an error message pops up: "<filepath and filename.svg> is not a valid Win32 application."
    So I started over:
    1-4. Same as above.
    5. Click on "Browse" to find the Illustrator.exe program file directly. I did this twice:
         a. First with the "Adobe Illustrator CS4" shortcut at: "C:\Program Files\Adobe\Adobe Illustrator CS4\Adobe Illustrator CS4.lnk". This takes me back to the "Open With" window, with the bad "Adobe Illustrator CS4" listing highlighted.
         b. Then with the actual program at: "C:\Program Files\Adobe\Adobe Illustrator CS4\Support Files\Contents\Windows\Illustrator.exe". This takes me back to the "Open With" window with "Adobe Illustrator CS3" highlighted.
    What can I do to fix this?
    Additional notes:
    1. I was able to use "Open With" to specify several browsers to open the SVG file. So the problem seems to relate specifically to the links to Illustrator CS4, rather than any overall "Open With" functionality.
    2. Right-clicking on an EPS file, and choosing "Open With," behaves exactly as right-clicking on an SVG file.
    3. Right-clicking an AI file show two instances of "Adobe Illustrator CS3"-- one with a CS3 icon and one with a CS4 icon. Clicking on each entry opens the correct program for the icon, however.
    How do I also fix this?
    Mike
    Message was edited by: Mike Wickham

    First an update: I compared registry entries with the CS4 installation on my laptop. I saw that quite a few of the Adobe.Illustrator.<etc>  keys were
    missing, and many of the ones that were there had CS3 paths listed instead of CS4. So I uninstalled Illustrator CS4 and reinstalled it. That fixed some
    problems. I also, in Windows Explorer, used Tools> Folder Options> File Types to change Illustrator CS4 to the default program to open AI, EPS, and
    SVG files. I chose "Advanced" and "Edit" in the File Type dialog and noticed that some of the entries for open were missing the "Open" action. So I fixed that.
    I've got the AI, EPS, and SVG files where I can open them with the correct programs now, but there are still some weirdities using right-click and Open With:
    For AI files:
        There are two instances of Adobe Illustrator CS3 listed. One has a CS3 icon. The other has the CS4 icon. The AI file opens with the program
    associated with the icon. If I choose Open With, then "Other Programs, there is a listing for Adobe Illustrator CS4, but it has a generic window icon and does not work. I get the "<path><filename>.ai is not a valid Win32 application" error.
    For EPS files:
      There are also two entries for Adobe Illustrator CS3, again one with a CS3 icon and one with a CS4 icon. Again they both open the program that matches the icon. There is also an Adobe Illustrator CS4 listed, but it has the shortcut icon for CS4 (the one with the arrow). It opens CS4. If I choose
    Other Programs, the non-working, generic icon Adobe Illustrator CS4 is also listed.
    For SVG files:
      There are also two Adobe Illustrator CS3 listings, one with a CS3 icon and one with a CS4 icon. There is also an Adobe Illustrator CS4 listed, but with the shortcut version of the icon. They all open the program associated with the icon shown. If I choose Other Programs, the listings and icons under "Recommended Programs" are correct for both CS3 and CS4, plus there is a CS4 listing with the generic icon.
    Is there any way to fix this stuff without uninstalling/reinstalling the whole Design Premium suite? While the reinstall of Illustrator CS4 did fix
    some things, it also broke some. It reinstalled a bunch of ancillary programs, like ExtendScript that I didn't tell it to reinstall. I ran Adobe
    update and now ExtendScript and and Adobe Drives service update fail to update. I ran the update from Acrobat. Looking in Illustrator, the update
    button is grayed out and completely unavailable.
    Mike

  • Accessing a public method from javascript in an applet!!!

    Hi!!
    I'm have an applet (named say applet.class) in an html page that has a public method like this....
    public void doShowFrame()
              Frame frame = new frame();
         frame.setVisible (true);
    What I want to do is to call that method with javascript, I've tried to do it like this...
    function show(){
    applet.doShowFrame();
    But when i press the button that launch the java scipt the browser says
    'applet' is unidentified...
    What's wrong, what can I do??

    http://www.google.com/search?q=applet+javascript+communication&sourceid=opera&num=0&ie=utf-8&oe=utf-8
    how hard was that? seriously.

  • Fontproblems and fontcaches in Illustrator CS4 and CS5

    Hello all,
    I've been having a serious and severe problem using Ilustrator and fonts.
    As this is a very complex problem to explain, I'll try to make it easy to understand.
    First I'll tell you the specifications and software used:
    Imac 27 inch running  MAC OS X 10.6.7 with follow software:
    Illustrator CS4 + Illustrator CS5, both installed
    Fontreserve (running a central server and macs connect through a MAC-client) http://www.extensis.com/en/support/font-reserve.jsp
    So we use an external third party fontsoftware to manage and activate our fonts used in Illustrator.
    We only have the required system fonts installed on our systems.
    We recently ran in a big issue concerning fonts within Illustrator.
    I'll try to explain what the problem really is ...
    So normally we boot up Illustrator and we activate our fonts in fontreserve.
    The fonts get loaded in Illustrator. So that does work like it should.
    But the problem begins when we deactivate fonts.
    Font reserve does deactivate them and in Illustrator the deactivated fonts are gone or so it seems ...
    After a restart, I only start Illustrator. So our client fontreserve stays closed.
    I opened the job I worked on before the restart and Illustrator opens the document and loads the fonts.
    You read it right, Illustrator does find all the fonts which, before the restart, were deactivated.
    Where does he gets those fonts?
    So I started to investigate and tried a couple of things.
    1) I physically moved the fontreserve-plugin out Illustrator so it will not be loaded on startup.
    That didn't fix it because Illustrator still finds the fonts.
    2) I physically plugged out the network cable to be sure Illustrator could not contact our fontserver.
    Sadly he still did find the fonts.
    3) I used "Tweak Freak" to clear my fontcaches. I also searched for "AdobeFnt" to clean out the cache from Adobe itself.
    This did not work either.
    4) I tried opening the document again but this time in CS5. And guess what? Illustrator CS5 asks for all the fonts that are missing, which is correct because not one font has been activated.
    Strangly enough I decided to reopen Illustrator CS4 (Illustrator CS5 still beiing open as well), and suddenly Illustrator CS4 asks for the fonts too?
    A minute ago he still found all the fonts and after opening Illustrator CS5, it does not ...
    So Adobe what is the connection between Illustrator CS4 and CS5?
    And where does Illustrator store its fontcache?
    It would be nice to run a script on shutdown te delete all possible fontcaches.
    So after spending a couple of hours fixing this problem, it seems that I still don't quite understand where the problem lies.
    I'm hoping you can.
    As this is an urgent matter, I hope to get an answer or support as soon as possible.
    Thanks in advance.

    You should be able to see what files Adobe Illustrator has open by using the Activity Monitor.app application.
    To do so, open the Activity Monitor application (it's in the /Applications/Utilities/ folder). Locate Adobe Illustrator in the list and then double-click on it. This should open up a new window like shown in the image below:
    Switch to the Open Files and Ports tab, and it should list every open file that Illustrator is using.

  • About  cursor  resource in illustrator CS4 SDK

    How to add cursor resource in CS4 ?
    /** Defines the cursor displyed when the MarkedObjects tool is selected
    and the cursor is over a document. The first 32 bytes define the cursor and
    the next 32 bytes define the mask, the last item is the h and v
    point of the hot spot.
    resource 'CURS' (kMarkedObjectsCursorID, locked, preload) {
    $"80 00 C0 00"
    $"E0 00 F0 00"
    $"C8 00 88 00"
    $"84 88 44 D8"
    $"42 A8 22 88"
    $"27 BE 19 AA"
    $"10 AA 08 A2"
    $"0F BE 00 00",
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00"
    $"00 00 00 00",
    {0, 0}
    who can know its face ?
    if I want to add a especial cursor ,how to edit these number?

    Hi,
    I also had this problem on a Mac and I found the following solution.
    1. I draw my cursor with Resorcerer.
    2. In Resorcerer, I select my CURS resource then I click the Hex button. In the window, I select and copy the column named Hex Data.
    3. I past the result in TextEdit.
    4. I launch a little application I did with AppleScript to convert the text in the good format to b used with XCode and Illustrator CS4
    Here is my little application to convert a text in TextEdit to the gool format.
    Maybe, this will be useful…
    If there is a better solution, I am intersted.
    JLG.

  • Illustrator CS4 restarts itself immediately after I quit it

    This happens pretty much every time I quit Illustrator. So I'd like to find a remedy.
    I'm running OS X.5.4 on a new iMac 3.06 GHz Dual with 4GB RAM Illustrator CS4 v14.0.0.

    Thanks, Wade. I trashed my AI settings folder in user preferences, and 
    that handled the problem.
    BTW, I love CS4 Premium Design Suite. You guys did a great job on CS4. 
    I think it was a better upgrade than CS3, which is saying a lot, as we 
    got a lot of mileage out of that version. Illustrator is better than 
    ever with all of its new features and refinements. It's so much 
    faster, too. Perhaps my new iMac 3.06 GHz has helped with that, too.
    I don't know what it is with various posters on Macworld article 
    comments threads, but there are a number of chronic "Adobe bashers" 
    who always carp about the "bloatware" and high prices. With my screen 
    name, "adobephile" I'm of course called a shill by those guys, but I 
    really love your products, and I've been using them to make my living 
    as a full time freelancer since I bought the first version of Adobe 
    Illustrator in the spring of 1987.
    It was very exciting. I plunked down my $500 and got one of those big 
    green slip cases with Botticelli's "Venus" smiling benignly back at 
    me. The package included a VHS video of John Warnock himself demoing 
    the program. He was also sincerely excited about the product.
    I had the advantage of having studied the Postscript language from 
    reading Adobe's books on the subject, and I realized that Illustrator 
    was essentially a GUI for the language.
    Thanks again for being there over the years and for continually 
    getting better and better.

Maybe you are looking for