How to script for resize CS3 indesign

Hi there,
I've been trying to search the internet for a script that I can use in the following situation.
I already use this script to center the content:
myObj = app.selection[0];
myObj.fit(FitOptions.centerContent);
the next step I would like to do...after inserting a pdf file within a rectangle frame (that being the "image box"). I would like to, after using the above script, resize the contents of the rectangle frame to whatever percentage for both X and Y (scale X Percentage, as well as Y, both different values).
Any help would be much appreciated. Also, the indd files are all named different, as well as the pdf's being inserted.

Here's a very basic sample script to get you started:
if (app.documents.length == 0) exit();
if (app.selection.length == 0) exit();
var sel = app.selection[0];
if (sel.constructor.name != "Rectangle") exit();
var pdfFile = File.openDialog("Choose a PDF File");
if (pdfFile == null) exit();
app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia; // General > Options > Crop to
var pdfPage = sel.place(File(pdfFile))[0];
with (pdfPage) {
     absoluteHorizontalScale = 40; // Horizontal Scale
     absoluteVerticalScale = 60; // Vertical Scale
sel.fit(FitOptions.centerContent);
It inserts the 1st page of the selected PDF file. If you want to insert specific pages, use app.pdfPlacePreferences.pageNumber property.
Kasyan

Similar Messages

  • Any script for PowerMath Equation (InDesign CS4)

    Hi,
    All, I'm new to Indesign Scripting, and I'm hoping someone can help me.
    Is that possible any type of script (Apple/Java) for edit/update Poermath Eqation in Indesign CS4.
    In my Knowledge (not found) Powermath Editor have no Dictionary. Is that possible we make script for Powermath Editor.
    Thanks for answering.
    Regards
    snegig

    You can try it like this. (Tested on Mac OSX)
    // export indesign doc to idml
    // tested on Mac OSX
    // this code is Public Domain
    // check if the doc is saved
    var doc = app.activeDocument;
    if (!doc.saved) {
      doc.save();// if not save it
    // take the .indd's name and make a .idml from it
    var aName = doc.name;// get the name
    var newName = aName.replace("indd", "idml");// replace the indd to idml
    // crate a new FIle Object
    var theFile = File(File(doc.filePath).fsName + "/" + newName);
    // export
    doc.exportFile(ExportFormat.INDESIGN_MARKUP, theFile, false);
    // done

  • How come script for cursor doesnt work in jsp pg?

    it works in an html pg but it doesnt work in a jsp page when i put in a javascript for an animated cursor btw the body tags:
    <script>blah</script>
    WHY? thanks

    WHY?Because it doesn't like you.
    View source on the generated JSP page.
    Compare it to the html page.
    Save the source as a static html file.
    Find what is causing the problem - maybe a javascript error on the page that prevents your code running?
    If you have IE, Tools:options: advanced tab, and uncheck "disable script debugging" so you can see the error messages - or get a browzer with a decent javascript debugger.
    Good luck,
    evnafets

  • How to listen for resizing of JTable column

    Is there anyway to tell when the columns in a JTable are being resized by the user? I couldn't find any listeners or anything that will tell you when the user is dragging the column width with the mouse.
    Thanks.

    Use ColumnModelListener as shown below:-
              table.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
                   public void columnAdded(TableColumnModelEvent e) {
                   public void columnMoved(TableColumnModelEvent e) {
                   public void columnRemoved(TableColumnModelEvent e) {
                   public void columnMarginChanged(ChangeEvent e) {
                   public void columnSelectionChanged(ListSelectionEvent e) {
              });

  • How Can I write Script for Indesign set left indent

    I really need two scripts for indesign set left indent:
    1. If the left indent is: 8, 16, 24, 32, 40, 48, 56mm... set the first -8mm; if the left indent is 0, set the left indent 8mm, first -8mm.
    2. Whatever the first indent is, set the first 8mm.
    Can someone help me?

    Hi, Trevor
    I use change by list as below:
    grep {leftIndent:48mm} {leftIndent:56mm}
    grep {leftIndent:40mm} {leftIndent:48mm}
    grep {leftIndent:32mm} {leftIndent:40mm}
    grep {leftIndent:24mm} {leftIndent:32mm}
    grep {leftIndent:16mm} {leftIndent:24mm}
    grep {leftIndent:8mm} {leftIndent:16mm}
    grep {firstLineIndent:8mm, leftIndent:48mm} {firstLineIndent:8mm, leftIndent:56mm}
    grep {firstLineIndent:8mm, leftIndent:32mm} {firstLineIndent:8mm, leftIndent:48mm}
    grep {firstLineIndent:8mm, leftIndent:24mm} {firstLineIndent:8mm, leftIndent:32mm}
    grep {firstLineIndent:8mm, leftIndent:16mm} {firstLineIndent:8mm, leftIndent:24mm}
    grep {firstLineIndent:8mm, leftIndent:8mm} {firstLineIndent:8mm, leftIndent:16mm}
    grep {firstLineIndent:-8mm, leftIndent:48mm} {firstLineIndent:-8mm, leftIndent:56mm}
    grep {firstLineIndent:-8mm, leftIndent:32mm} {firstLineIndent:-8mm, leftIndent:48mm}
    grep {firstLineIndent:-8mm, leftIndent:24mm} {firstLineIndent:-8mm, leftIndent:32mm}
    grep {firstLineIndent:-8mm, leftIndent:16mm} {firstLineIndent:-8mm, leftIndent:24mm}
    grep {firstLineIndent:-8mm, leftIndent:8mm} {firstLineIndent:-8mm, leftIndent:16mm}
    but not that perfect,
    I want to useing jave "if{}" or "for{}" to write this script, but I don't kown the syntext.

  • [CS3]How to export a table in InDesign to an excel file?

    Hi,
    Can any one tell me how to script the process of exporting a table to excel file in InDesign CS3 using javascript?
    Thanks in advance.
    myRiaz

    Sorry, no javaScript, but here are some lines from a localization tool that I made in VB. I simply loop through the Rows and Columns and use the Excel DOM to fill the Excel-cells.
    Of course you can read amended/localized Excel files back into inDesign the same way, provided that the tables match (nr of rows and columns).
    Afterwards you could loop through the characters of each cell to apply the formatting that you want to keep in Excel, such as SuperScripts.
    Hope it helps you.
    Set myExcel = CreateObject("Excel.Application")
    myExcel.Visible = True
    Set myTableBook = myExcel.Workbooks.Add
    Set myTableSheet = myTableBook.Worksheets.Item(1)
    myTableSheet.Columns.ColumnWidth = 35
    myTableSheet.Cells.VerticalAlignment = xlVAlignTop
    myTableSheet.Cells.WrapText = True
    For R = 1 To myTable.Rows.Count
        Set myTableRow = myTable.Rows.Item(R)
        For C = 1 To myTableRow.Cells.Count
            Set myTableCell = myTableRow.Cells.Item(C)
            If Len(myTableCell.Contents) = 0 Then
                myTableSheet.Cells(R, C) = ""
            Else
                myTableSheet.Cells(R, C) = myTableCell.Contents
                myTableSheet.Cells(R, C).Value = Replace(myTableSheet.Cells(R, C).Value, "1397058884", "—")
                myTableSheet.Cells(R, C).Value = Replace(myTableSheet.Cells(R, C).Value, Chr(13), Chr(10))
            End If
        Next C
    Next R
    good luck
    TonyT 

  • Is there an updatedcrossrefs script for InDesign CS6

    Running Mac Pro/2.66 GHz—Quad-Core Intel Xeon/Snow Leopard/
    OS/Mac OS X Version 10.6.2/2.66 GHz
    I converted a CS3 InDesign that uses the script "updatedcrossrefs.js", to CS6 InDesign. This file uses hyperlinks on the TOC and Index.
    I tried using the same script for CS3 InDesign in CS6 InDesign but it does not work.
    This is the error message "Could not catch page. Check destination names and existence."
    Is there an updated script for CS6?

    Sorry did not know I was using bold. My co-worker found this script however, she does not work here anymore. But here is the script. I know nothing about scripts except how to use them. Sorry.
    // Updatecrossrefs.js
    // Updates cross references made with hyperlinks
    // the hyperlink destination is where the reference refers to
    // the hyperlink sourcetext is the text that will be updated (like see xx)
    // If a book is open, the book will be handled,
    // if no book is open, the active document will be handled.
    // Made by Teus de Jong, last version April 10, 2006
    // Revisions by Dave Saunders January 22, 2006 and March 20, 2006
    // Thanks Dave!
    // Added unique naming mechanism for sources -- October, 2008
    if (app.books.length == 0){
              if (app.documents.length == 0){
                        errorExit('No documents are open');
              } else {
                        nrofdocs = 1;
                        doc = app.activeDocument;
    } else {
              nrofdocs = app.books[0].bookContents.length;
              for (i = nrofdocs - 1; i > -1; i--) {
                        if (app.books[0].bookContents[i].status != BookContentStatus.documentIsOpen)
                                  app.open(File(app.books[0].bookContents[i].fullName));
              doc = app.open(app.books[0].bookContents[0].fullName);
    for (d = 1; d <= nrofdocs; d++){
              for (i = 0; i < doc.hyperlinks.length; i++){
                        hyper = doc.hyperlinks[i];
                          // leave ID's own internal markers alone
                        if (hyper.name.substring(0, 1) == '.'){continue}
                          // leave hyperlinks to URLs alone
                          try {
                                  if (hyper.destination.constructor.name == 'HyperlinkURLDestination'){continue}
                        } catch (e) {
                                  hyper.showSource();
                                  errorExit('Selected hyperlink has undefined destination');
                        s = hyper.source.name;
                        // added October, 2008
                        // sometimes ID's unique name mechanism for sources fails; make sure the source has
                        // the same name as the hyperlink + '_src'
                        if (s != hyper.name + '_src')
                                  hyper.source.name = hyper.name + '_src';
                        if (hyper.destination.constructor.name == 'HyperlinkTextDestination'){
                                  s = getParentPageName(hyper.destination.destinationText);
                         } else {
                                   // try/catch added to allow for hyperlinks that have lost their destination -- Dave
                                   try {
                                              s = hyper.destination.destinationPage.name;
                                    } catch (e) { continue }
                        if (s != ''){
                                  // Check to see if update needed; saves a lot of time when processing large books -- Dave
                                  if (hyper.source.sourceText.contents != s) {
                                            hyper.source.sourceText.contents = s;
              if (d >= nrofdocs){
                        break;
              doc = app.open(app.books[0].bookContents[d].fullName);
    function getParentPageName(txt){
              try { 
                        var myFrame = getParentTextFrame(txt);
                        var pag = myFrame.parent;
                        while (pag.constructor.name != 'Page'){
                                  // in case the reference is in an inline, the parent of the frame is a character
                                  if (pag.constructor.name == 'Character'){
                                            pag = getParentTextFrame(pag);
                                  // in case the chain goes sour, back out
                                  if (pag.constructor.name == 'Application'){
                                            throw 'Error';
                                  pag = pag.parent;
                        return(pag.name);
              catch (e) {
                        alert('Could not catch page.\nCheck destination names and existence.');
                        return('');
    function getParentTextFrame(x){
              if(app.version == 3){
                        return(x.parentTextFrame);
              else {
                        return(x.parentTextFrames[0]);
    function errorExit(s){
              alert(s);
              exit();

  • How to select a spread in Indesign CS3?

    Hello All!
    Can somebody give me an idea how to select a spread in Indesign CS3 ?
    The simplest script
    #target indesign
    var myDocument = app.documents.item(0);
    app.activeWindow.zoom(ZoomOptions.FIT_SPREAD);
    for (j=0; j < myDocument.spreads.length; j++) {
           app.select(myDocument.spreads[j]);
           alert("j: " + j);
    Windows XP is used, and here this script works in CS4 and CS5 absolutely correct -- I see what it jumps from one spread to next and shows in alert message an index of current spread.
    But in CS3 the program only calculates number of next spread but on screen I see the same layout.
    May be there is an another way to select spread?
    Thank you.
    Mikhail

    app.activeWindow.activeSpread = myDocument.spreads[j];
    app.activeWindow.zoom(ZoomOptions.FIT_SPREAD);

  • Script for InDesign CS6 - create multiple, prenamed layers

    I created a script for Illustrator CS6, in ExtendScript Toolkit, that will create multiple, prenamed layers...see below...
    //Apply to myDoc the active document
    var layerName = LayerOrderType;
    var myDoc = app.activeDocument;
    //define first character and how many layers do you need
    var layerName
    var numberOfLayers=0;
    //Create the layers
    for(var i=0; i<=numberOfLayers; i++)
    { var layerName = ":: GRADIENT";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = ":: STRIPES";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = ":: LEGAL";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = ":: BLK BAR";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = ":: FLAME";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = ":: LOGO/TYPE";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = ":: TRIM,ETC";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = ":: LOEC INFO";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    // Moves the bottom layer to become the topmost layer
    if (documents.length > 0) {
    countOfLayers = activeDocument.layers.length;
    if (countOfLayers > 1) {
    bottomLayer = activeDocument.layers[countOfLayers-1];
    bottomLayer.zOrder(ZOrderMethod.BRINGTOFRONT);
    else {
    alert("The active document only has only 1 layer")
    I tried to use this exact code to replicate the same scenario in InDesign but it doesn't work.
    Can anybody help me out!?
    Thanks in advance

    Marijan Tompa's scripts are very nice and useful, however, for this simple task you can try create your own wiht this code:
    app.activeDocument.layers.add ({name: "GRADIENT", layerColor: UIColors.red});
    app.activeDocument.layers.add ({name: "STRIPES", layerColor: UIColors.lightBlue});
    app.activeDocument.layers.add ({name: "LEGAL", layerColor: UIColors.gray});
    //merge existing document layer to bottom layer (in this case original layer will be merged to 'GRADIENT')
    var myDocument = app.documents.item(0);
    var myLayerA = myDocument.layers.item(2);
              var myLayerB = myDocument.layers.item(3);
              myLayerA.merge(myLayerB);
    alert("Layers created!");
    assume, your document has one layer.
    Script creates three new layers, they appear in Scripts palette in this order:
    LEGAL
    STRIPES
    GRADIENT
    and merges 'old' layer to bottom layer of newly created set (GRADIENT).
    sure, you can add as much layers as you need, just don't forget modify LayerA and LayerB numbers accordingly.
    Or disable second part of the script at all, if you don't want anything to be merged.

  • I upgraded from snow leopard to mavericks only to find that my backup files of all my CS3 indesign, illustrator, photoshop wo't run, how do I uninstall mavericks and get my old system back

    I upgraded from snow leopard to mavericks only to find that my backup files of all my CS3 indesign, illustrator, photoshop wo't run, how do I uninstall mavericks and get my old system back.  I retired from graphics a few years back but still have old clients I do work for and maintain files for.  Would not have upgraded if I had known of the incompatability.

    You did not due any due dilligence to investigate if your legacy apps would run, you should upgrade your apps. However if you feel you have to downgrade back to SL then click
    https://discussions.apple.com/docs/DOC-6162
    for directions.

  • Script for CS3 won't work in CS2

    Hello all,
    I am new to scripting and trying to get a script written for CS3 to work in CS2. The script was given to me a participant in the InDesign forum. At any rate, here is the script:
    for (n=0; n<app.selection.length; n++) {
    app.selection[n].move([23.44, 100.05]);
    I get an error messsage that says
    error #19
    error string "bad argument move"
    Line: 2
    Source: "app.selection[n].move([23.44, 100.0});"
    Offending text: "100.0"
    As i said I am new to scripting and have been perusing the scripting manual but cannot gather what my error was, and I am trying to meet a deadline.
    Cheers in advance!

    Ok, me again.
    I got it working - well, it moves the text boxes I select - but for some reason the Y variable isn't coming out correctly.
    For example, if I use the coordinates 32.385, 16.231 in a script, it moves it to the correct spot on the X axis, but the coordinate for the Y will be off. Further, depending on what text box I select to move, it will vary (by 1-5 mm) along the Y axis. Different text boxes go to different areas along the Y axis, but never far from the script coordinate.
    So I guess there does need to be some alteration made? I'll post this in the script forum too, not really sure where it belongs with this particular problem.
    Bleah.

  • Indesign Contact Sheet script for Adobe Bridge 1.0.4.6

    Our company currently has all the Adobe CS2 products but as stand alone applications and not part of the Creative Suite. Therefore, we don't seem to have all the functionality of the suite.
    In particular the script to create Contact Sheets from Indesign CS2 of items through the script in Adobe Bridge.
    Can anyone tell me if there is a way to add the functionality of the contact sheet script for Indesign to Bridge without having the Adobe Creative Suite? And Why?
    We are looking for something to replace an extension used by Quark to create contact sheets from Badia software. I am loath to upgrade this extension unless absolutely necessary. We receave thousands of photo's a week and output contact sheets for our editors to pick and choose which photos they want/like.
    Thanks in advance.
    Scott

    [email protected] wrote:
    > Larry
    > for us to process thousands of photos this way would take hours.
    Why? Are you talking CPU hours or staff-hours? Does your workflow require heavy
    user interaction or is something else the problem?
    -X
    for photoshop scripting solutions of all sorts
    contact: [email protected]

  • Need Help Creating A Script For Labeling Finder Files from Indesign

    Trying to figure out a way to have a script run in InDesign CS4 that will label a text file RED after it's been imported into InDesign.
    We import numerous text files into an InDesign template. Since there are several text files in the same folder, we need to somehow "mark off" that we've imported that file and move to the next one to import. I have created an Automator "service" with a keyboard shortcut to label the file Red in the finder but it would be great if we could have this happen automatically after we import into InDesign.
    If we import the wrong text file by accident and it gets missed in proofing, it costs us a lot of money with the printer.
    Thanks for any ideas.
    Jim

    You know, these guys are absolutely right in their assessment that this is a good place for event listeners. You would need three scripts though.
    Something like...
    Label Placed Files Red.scpt
    --Put this in a folder called IDScripts in your Documents folder
    main(evt)
    on main(myEvent)
    tell application "Adobe InDesign CS4"
    set placedFilePath to full name of myEvent
    set placedFilePath to placedFilePath as alias
    end tell
    tell application "Finder"
    --This turns the file color red
    set label index of placedFilePath to 2
    end tell
    end main
    And these two are in your InDesign scripts folder...
    Start Placed File Finder Labelling.scpt
    --Installs the afterImport event listener for the Label Placed Files Red script.
    tell application "Adobe InDesign CS4"
    set myHandler to path to documents folder
    set myScriptName to "Label Placed Files Red.scpt"
    set myHandler to "" & myHandler & "IDScripts:" & myScriptName
    try
    set myHandler to myHandler as alias
    make event listener with properties {event type:"afterImport", handler:myHandler, captures:true}
    display dialog "Placed File Labelling: ON" buttons "OK" default button 1
    on error
    display dialog "ERROR: Couldn't start handler!" & return & return & "Make sure the \"" & myScriptName & "\" script in a folder called \"IDScripts\" inside your Documents folder and try again" buttons "OK" default button 1
    end try
    end tell
    Stop Placed File Finder Labelling.scpt
    --Removes the afterImport event listener for the Label Placed Files Red script.
    tell application "Adobe InDesign CS4"
    set myHandler to path to documents folder
    set myScriptName to "Label Placed Files Red.scpt"
    set myHandler to "" & myHandler & "IDScripts:" & myScriptName
    set myHandler to myHandler as alias
    set myResult to remove event listener event type "afterImport" handler myHandler with captures
    if (myResult is false) then
    display dialog "ERROR: Couldn't remove handler! Are you sure it is active?" & return & return & "If so, please quit and relaunch InDesign to get rid of it." buttons "OK" default button 1
    else
    display dialog "Placed File Labelling: OFF" buttons "OK" default button 1
    end if
    end tell

  • How to make an insert script for CLOB data types?

    I need to have an insert script for Oracle 11g where I insert large texts into a CLOB field
    I exported data from a source table using TOAD's export dataset and the insert statements option, so it generates a script of just simple insert into statements with the clob strings in the values clause within single quotes.
    While most of the inserts succeed, several fail with the error: string literal too long
    How can I insert long texts into clobs?
    One workaround I was considering, is maybe breaking up those inserts which are too big, so that it inserts a chunk, and then does an update to append additional chunks? not sure if that would work either
    first wanted to get any ideas from the oracle experts here in case there is a much easier, non-manual labor intensive way.

    Thank you for that informative link, Raj
    I wouldn't be able to use SQL Loader for this though, this is something that gets submitted to a DBA in a request and it must be in a script that can be run in Sql Plus, and it cannot pull it from a table or file.

  • Scripting for different numbers of table rows in cs3

    As always thank you for the help.
    My question: is there a simple newbie way to script for stroke placements when the numbers of rows in the category between the stroke will vary. I have not even attempted to script this style, as frankly I don't know where to start, but here is an explanation of what I need:
    The table foodstuff contains:
    animal, vegetable, fruit
    Under animal there is:
    beef, lamb, pork, poultry
    Under vegetable there is:
    potato, pepper, onion
    Under fruit there is:
    orange
    If wanted a line under each category, ie after poultry, after onion, and after orange how would I go about it.
    Thank you to all who have helped me so far, either by reading answers to other people's queries, or by responding directly to my own

    Interesting ... I don't think there is a newbie-level answer to this challenge. It comes down to finding the first (left-to-right) cell that contains text, and adding a line on top of it all the way to the last cell in that row.
    Here's a first attempt:
    table = app.selection[0];
    if (table.hasOwnProperty("baseline"))
    table = table.parent;
    if (table instanceof Cell)
    table = table.parent;
    if (table instanceof Column)
    table = table.parent;
    if (table instanceof Row)
    table = table.parent;
    if (table instanceof Table)
    table.cells.everyItem().properties = {topEdgeStrokeWeight:0, bottomEdgeStrokeWeight:0, leftEdgeStrokeWeight:0, rightEdgeStrokeWeight:0};
    table.rows.lastItem().bottomEdgeStrokeWeight = 1;
    for (r=0; r<table.rows.length; r++)
      for (c=0; c<table.rows[r].cells.length; c++)
       if (table.rows[r].cells[c].contents)
        for (; c<table.rows[r].cells.length; c++)
         table.rows[r].cells[c].topEdgeStrokeWeight = 1;
        break;
    } else
    alert ("You were supposed to be somewhere inside a Table");

Maybe you are looking for

  • NameNotFoundException while calling FormService generatePDFOutput in a process

    Hi All, I have created a process which calls only one service, that is FormService generatePDFOutput. I have created three variables xfaForm for form, Document variables for inputXMLData and outputPDF. I have assigned these variables in the generateP

  • Do wildcards have to be within bounds?

    Is it intended that the compiler accepts the following type declaration? class Wrapped<T extends Comparable> { ... } Wrapped<? super Number> wrapper3;  // <<<Number is not Comparable, and for this reason no supertype of Number is Comparable. Conseque

  • Putting a rollover gif into an iweb template

    hi, i am using iWeb for the first time and have created my website using a template but i want to add a gif to the page so when people roll over it, the picture changes. i have made the gif in photoshop and image ready and can only export it as an ht

  • Deleted Messages keep reappearing as new Mail

    Everytime I erase messages and close down when I open they all come back for the whole year as new mail and I have to wait till they are all loaded before I can get my new mail

  • Problem with desktop icons on lollipop

    After update on lollipop i transferred my games and some of my apps to SD card but the problem is when i restart my phone all icons of those app are deleted from desktop and need to reput them again, its very annoying