Can't figure out how to make this script work

Hey Folks,
Anyone here who would like to look at the following script and tell me where I made the error(s)?
I want to put this script in a Batch so that I can run it on a directory of files all with filenames like
Q-CAT 2010-01 Covers_v7bP01x.pdf and
Q-CAT 2010-01 Covers_v7bP02x.pdf
I put this script in the correct spot, but nothing happens... I tried the debugger console, and I get:
Begin Job Code
Processing File #1
State P01 detected
Batch aborted on run #1Error: NotAllowedError: Security settings prevent access to this property or method.
End Job Code
This is the script, it's supposed to run in Acrobat 9:
/* Q-CatCoverPagesSaveAs */
/* this script Crops CatCovers' Spreads and saves it into separate pages */
/* ©20100521 - AOP-Creatives, Willy Croezen */ 
// Begin Job 
if ( typeof global.counter == "undefined" ) { 
console.println("Begin Job Code"); 
global.counter = 0; 
// insert beginJob code here 
// Main Code to process each of the selected files 
try { 
global.counter++ 
console.println("Processing File #" + global.counter); 
// insert batch code here. 
function doCropPages()
   this.setPageBoxes({
      cBox: "Crop",
      rBox: cropLeft
    app.beginPriv();
console.println("Save LeftPageName");
//       this.saveAs(this.path.slice(1, fname.indexOf(pageSide)) + leftPageName);
    app.endPriv(); 
   this.setPageBoxes({
      cBox: "Crop",
      rBox: cropRight
   app.beginPriv();
console.println("Save RightPageName");
//      this.saveAs(this.path.slice(1, fname.indexOf(pageSide)) + rightPageName);
   app.endPriv();
//Declaration List
var Units = "mm"; 
var i = this.path.search(/[^:/]+\.pdf$/);
var fname = this.path.slice(i, this.path.length - 4);
var cropRect = this.getPageBox("Crop"); 
//Check if filename contains P01, indicating the Outside spread of a Catalog Cover. If so, crop accordingly
if (fname.indexOf("P01") != 0)
console.println("State P01 detected");
   var pageSide = "P01";
   var leftPageName = "P260.pdf";
   var rightPageName = "P001.pdf"; 
   var cropLeft = new Array();
      cropLeft[0] = cropRect[0];
      cropLeft[1] = cropRect[1];
      cropLeft[2] = cropRect[2];
      cropLeft[3] = cropRect[3] + 277.5; 
   var cropRight = new Array();
      cropRight[0] = cropRect[0];
      cropRight[1] = cropRect[1];
      cropRight[2] = cropRect[2] + 223.5;
      cropRight[3] = cropRect[3] - 62;
   doCropPages();
else
   //If filname does NOT contain P01, check if filename contains P02, indicating the Inside spread of a Catalog Cover. If so, crop accordingly
   if (fname.indexOf("P02") != 0)
console.println("State P02 detected");
      var pageSide = "P02";
      var leftPageName = "P002.pdf";
      var rightPageName = "P259.pdf";
      var cropLeft = new Array();
         cropLeft[0] = cropRect[0];
         cropLeft[1] = cropRect[1];
         cropLeft[2] = cropRect[2];
         cropLeft[3] = cropRect[3] + 223.5; 
      var cropRight = new Array();
         cropRight[0] = cropRect[0];
         cropRight[1] = cropRect[1];
         cropRight[2] = cropRect[2] + 277.5;
         cropRight[3] = cropRect[3];
      doCropPages();
   else
      // If filename doesn't contain P01 OR P02, give Error notice
console.println("Document is not correctly named! Should have P01 or P02 in it");
catch(e) {
console.println("Batch aborted on run #" + global.counter + "Error: " + e);
delete global.counter; // so we can try again, and avoid End Job code
event.rc = false; // abort batch
// End Job
if ( global.counter == global.FileCnt ) {
console.println("End Job Code");
// insert endJob code here
// may have to remove any global variables used in case user wants to run
// another batch sequence using the same variables, for example...
delete global.counter;

Hy Folks,
This thread can be closed, as I fixed the script! It turned out that I needed to put the function definition above the body-code for the script to find it. After that it was small details.
I created a conversion variable (UnitsConv) for the margins so you  can simply enter the desired dimensions in mm, instead of px, which I  thought was easier.
This script now perfectly processes the files  you put to it in a batch-operation (if correctly named with P01 and P02  in the filename.) and saves the resulting pages into the specified  temp-directory. This time the filenames reflect the original filenames,  for easy identification later, with the new pagenumbers appended to  them.
For your information (and perhaps for use as the base for a custom  script for yourself) I give you the final working version below.
This script will be trimmed down and become part of a larger script, or scriptset, which I will be using to automate the workflow of creating al different versions of lowres and highres catalogs that we need.
Kind regards,
Willy Croezen
/* Q-CatCoverPagesSaveAs v1.0*/
/* this script Crops CatCovers' Spreads and saves it into separate pages */
/* ©20100521 - AOP-Creatives, Willy Croezen */
// Begin Job
if ( typeof global.counter == "undefined" ) {
console.println("Begin Job Code ");
global.counter = 0;
// insert beginJob code here
// Main Code to process each of the selected files
try {
global.counter++
console.println("Processing File #" + global.counter);
// insert batch code here.
function doCropPages(crL,crR,lPName,rPName)
   this.setPageBoxes({
      cBox: "Crop",
      rBox: crL
      console.println("Save LeftPageName to: D:/temp/" + lPName);
      this.saveAs("/D/temp/" + lPName);
   this.setPageBoxes({
      cBox: "Crop",
      rBox: crR
      console.println("Save RightPageName to: D:/temp/" + rPName);
      this.saveAs("/D/temp/" + rPName);
//Declaration List
var UnitsConv = (72 / 25.4);
var i = this.path.search(/[^:/]+\.pdf$/);
var fname = this.path.slice(i, this.path.length - 4);
var cropRect = this.getPageBox("Crop");
//Check if filename contains P01, indicating the Outside spread of a Catalog Cover. If so, crop accordingly
if (fname.indexOf("P01") != -1)
console.println("Value fname.indexOf(P01) = " + fname.indexOf("P01"));
console.println("State P01 detected");
   var pageSide = "P01";
   var leftPageName = fname + "P260.pdf";
   var rightPageName = fname + "P001.pdf";
// Create array of crop-values. Sequence is left, top, right, bottom
   var cropLeft = new Array();
      cropLeft[0] = cropRect[0];
      cropLeft[1] = cropRect[1];
      cropLeft[2] = cropRect[2] - Math.floor(277.5 * UnitsConv);
      cropLeft[3] = cropRect[3];
   var cropRight = new Array();
      cropRight[0] = cropRect[0] + Math.floor(223.5 * UnitsConv);
      cropRight[1] = cropRect[1];
      cropRight[2] = cropRect[2] - Math.floor(62 * UnitsConv);
      cropRight[3] = cropRect[3];
   doCropPages(cropLeft,cropRight,leftPageName,rightPageName);
else
   //If filname does NOT contain P01, check if filename contains P02, indicating the Inside spread of a Catalog Cover. If so, crop accordingly
   if (fname.indexOf("P02") != -1)
console.println("State P02 detected");
      var pageSide = "P02";
      var leftPageName = fname + "P002.pdf";
      var rightPageName = fname + "P259.pdf";
// Create array of crop-values. Sequence is left, top, right, bottom  
      var cropLeft = new Array();
         cropLeft[0] = cropRect[0];
         cropLeft[1] = cropRect[1];
         cropLeft[2] = cropRect[2] - Math.floor(223.5 * UnitsConv);
         cropLeft[3] = cropRect[3];
      var cropRight = new Array();
         cropRight[0] = cropRect[0] + Math.floor(277.5 * UnitsConv);
         cropRight[1] = cropRect[1];
         cropRight[2] = cropRect[2];
         cropRight[3] = cropRect[3];
      doCropPages(cropLeft,cropRight,leftPageName,rightPageName);
   else
      // If filename doesn't contain P01 OR P02, give Error notice
console.println("Document is not correctly named! Should have P01 or P02 in it");
catch(e) {
console.println("Batch aborted on run #" + global.counter + "Error: " + e);
delete global.counter; // so we can try again, and avoid End Job code
event.rc = false; // abort batch
// End Job
if ( global.counter == global.FileCnt ) {
console.println("End Job Code");
// insert endJob code here
// may have to remove any global variables used in case user wants to run
// another batch sequence using the same variables, for example...
delete global.counter;

Similar Messages

  • 3-d Problem.....can't figure out how to make this????

    I've attached a logo i have to recreate for a customer. How do i recreate the rings??? i've tried in 3-D in revolve but the ring is always to fat. I can't get it to make it skinnier. Any one know what i'm doing wrong or have a way to fix this????

    I saw a tutorial on making springs and that could be used to do your rings.
    http://vector.tutsplus.com/tutorials/tools-tips/how-to-create-funky-3d-springs-in-illustra tor/

  • Can't figure out how to make "sub-tabs" / Too many "top-tabs" / Other ?

    First of all, the website that I am webmaster for is: www.cindydennis.org .
    I am having some problems:
    1) There are TOO MANY tabs at the top. I can't figure out how to make sub-headings on one page...
    For example, I'd like on the "About CDM" page, tabs that can be clicked on to go to other information tabs, but that don't end up appearing on the top (e.g.: having "Remarks" and "What We Believe" tabs go there, but not appear at the top).
    Another example, if you look at the home screen, I'd like to have the link to the "Privacy Policy" and Terms of Service" pages on the bottom, but not have them appear as tabs in the top, too.
    How do I do this, please? I've searched, and can't figure out/___sbsstatic___/migration-images/migration-img-not-avail.png
    2) How do I add "Copyright 2011" automatically? I saw in the Rapidweaver trial version, it automatically adds it when you publish... is there a way to tell this program to do this? Or do I need to type that in on each page? (I don't want to purchase RW... I'm not ready for that yet.)
    Thank you in advance
    Cindee

    Cindee ~ One way to do the copyright notice is to use a Text Clipping — Select (highlight) the copyright text you want to use and drag it to the Desktop. If necessary, change the name of the Clipping icon so that it's more easily identifiable on the Desktop. Then, when you need it in iWeb, simply drag the Clipping icon from the Desktop to iWeb's main canvas.
    By the way, rather than posting your URL here like this:
    www.cindydennis.org
    ...include the prefix to make it conveniently clickable:
    http://www.cindydennis.org

  • I filmed several takes of the same scene for a movie. I trimmed the best clips from each take and put them into the project screen. However, I can't figure out how to make it flow seamlessly as one scene. Can someone please help me??

    I filmed several takes of the same scene for a movie. I trimmed the best clips from each take and put them into the project screen. However, I can't figure out how to make it flow seamlessly as one scene. Can someone please help me??

    1-800-676-2775  apple support   tech support 1 800 275 2273
    If your computer is on one minute before it freezes, than you have one minute to secure your serial number.
    click the apple----->click about this Mac ------> click on version----> until you see the serial number.  You may have to do this a couple of times if it freezes before you have all the numbers.  A camera might help.
    Good Luck

  • My new nano keeps going into sleep mode every copy of minutes while music is playing.  I can't figure out how to stop this.  The user guide isn't too helpful.  Any ideas?

    My new nano keeps going into sleep mode every copy of minutes while music is playing.  I can't figure out how to stop this.  The user guide isn't too helpful.  Any ideas?

    This is usually a sign that your iPod's headphones are not plugged in all the way.  Make sure that you cannot see any of the silver still showing from the headphone's plug.  You should hear a sort of popping/clicking noise when inserting the headphones letting you know that they have been fully seated.
    B-rock

  • Ever time I make a call on my iPhone 4 my FaceTime icon has a question mark in the middle of it. I can not figure out how to make it go away. Nor can I make a FaceTime call.

    Ever time I make a call on my iPhone 4 my FaceTime icon has a question mark in the middle of it. I can not figure out how to make it go away. Nor can I make a FaceTime call. Do I need to install a FaceTime App on my phone?

    No, your FaceTime is build in, see this article for more info: iOS: Using FaceTime
    Did you enable restirctions for FaceTime in Settings/General/Restrictions ->FaceTime?
    Is FaceTime enabled in Settings/Phone?

  • Please Help!  I have been writing using - Pages - app for years.  I still can not figure out how to make single spaces between paragraphs.  Pages automatically double spaces between paragraphs.

    I have been writing on - Pages- app for several years.  Pages automatically uses double space between paragraphs. I can not figure out how to make single space between paragraphs. Tried everything.  Please help!  

    Pages User Guide >  http://manuals.info.apple.com/en_US/Pages_UserGuide.pdf
    Open the user guide then press Command + F on your keyboard.
    Type line spacing in the search field top right corner of that window.

  • Trying to enter hotel password and 1st letter is always upper case and password is lower case.  Can't figure out how to make 1st letter lower case

    I am trying to enter a hotel password for internet access.  The password is all lower case, but the 1st letter I type is always upper case and I can't figure out how to make it lower case.  Help?

    The digital keyboard on the iPad uses an "Up Arrow" as a symbol to represent its shift key(s). If it's highlighted, then the next letter typed will be upper-case. Just tap on the Arrow symbol and it should be unhighlighted. Now if you type any letter, it will be lower-case.

  • After 10.8.4 Update, I receive a series of capital A's in a box in some of the email signatures I receive. I can not figure out how to correct this.

    After 10.8.4 Update, I receive a series of capital A's in a box in some of the email signatures I receive. I can not figure out how to correct this.

    Back up all data.
    Launch the Font Book application and validate all fonts. You must select the fonts in order to validate them. See the built-in help and this support article for instructions. If Font Book finds any issues, resolve them, then boot in safe mode to rebuild the font caches. Boot again as usual and test.
    Note: If FileVault is enabled under OS X 10.7 or later, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode. In that case, ask for instructions.

  • I keep getting a message on my phone that i need to update my email password. I can not figure out how to do this.

    I keep getting a message on my phone that i need to update my email password. I can not figure out how to do this.

    Hi there!
    Not knowing anything more than what you've posted (e.g., email provider, text of the request, etc.), we can only surmise that this must be the password revalidation that HotMail and other providers send out on a periodic basis. Here is the KB that discusses what to do:
    http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB13137
    Hopefully that will help you.
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I would like to set a block feature for Firefox Safe Mode. I can't figure out how to do this on McAffee. Help please.

    I found out that my boys can get into 'safe mode' which bypasses all blocks. I went to my McAfee home page and can't figure out how to block this browser. Can you tell me how??? THANKS!

    Create a contact for yourself either in the phone app or the contacts app. Then go - Settings > General > Siri > My Info > Set your contact.

  • Can't Figure Out How to do This

    There's something I've been doing on my Treo 650 that I can't seem to figure out any way to do on my new iPhone 3G. Sorry for the somewhat "long story" here, but
    My wife is Chinese, so as we live our lives together, I have been keeping a continuously running "memo" on my Treo, into which I have periodically typed English words and phrases that would be valuable to learn Chinese equivalents for. So, whenever such a word comes up in life, I pop out that memo on my Treo, add a word to it, and put it away.
    Of course I have kept that, and everything else, sync'ed up with my Mac, so I can see those new words and phrases there too.
    To actually learn these new words and phrases, once every few months, I copy those new words into a spreadsheet, figure up translations for them, and study the result as new Chinese-language lessons.
    So, on the iPhone, it appears that I can do almost all of this using "Notes." But there are two things I can't figure out how to do:
    1. Back up (i.e., sync) that memo to my Mac routinely. Yes, I do see that I can Email it to myself periodically, but that's not quite the same as having a document on the iPhone "automatically" backed up on the Mac.
    2. I don't see any way to bring what I already have on my Treo into a "Note" on the iPhone. If I could copy and paste, I could Email that text to myself and then copy&paste it from that Email into the Note, but there's no copy&paste on the iPhone. I do see that there are "Notes" in the Email application, but those are not editable on the iPhone. They are visible on the iPhone, but can't be edited there. Even if they were editable, they still clutter up my inbox, but perhaps I could devise a "smart mailbox" to address that.
    In the first regard, Emailing is marginally acceptable, but I don't have any idea what to do about the second.
    Thanks for any ideas you might have!

    I'm another one of the very grumpy customers regarding the problems synching Outlook calendars with the new 2.0 iPhone.
    I have another twist: I did not ever have multiple calendars in Outlook until the 2.0 update; I had just one. After I updated the iPhone software to 2.0 I have multiple calendars which I did not create. My iPhone has all the events listed, color coded by these various calendars, but when I look at my calendar(s) in Outlook, I can not see all the events at once. So my iPhone is the most complete, and my computer version is fragmented. This is an unacceptable royal pain. I'm relieved to know it's not just me, my iPhone, my Outlook, etc., but I'm definitely one of the many of us who are grumpy with Apple and impatient for their fix.
    My question is: how do I sync my Outlook to my iPhone and delete all these calendars without deleting events? I just want one calendar again: mine, all mine.
    PS I do have recurring events, but way too many to hand change them all; that's ridiculous. Even if I didn't have many of those it's ridiculous that the recurrences should create these problems. It's a pretty basic electronic calendar function.

  • The window displaying bookmarks is too large (suddenly happened with the new version). I can't figure out how to make the display smaller. Zooming out does not work on the bookmark menu display.

    I have version 4, just downloaded, and a Mac w. OS 10.6. 7.
    The bookmarks display (when I pull down "bookmarks") is much too wide. I can't figure out how to reduce the display size. The window is not persistent so I can't even get you a screen shot.
    Thanks, Sara

    It seems there was a change in Firefox 4 where the width of the drop-down is now determined by the length the longest bookmark name in the folder being displayed. Previous versions of Firefox would shorten a long name like that and add an ellipsis to signify the name was truncated.
    Sorry, I don't know how to change that other than to advise you to edit the name of that long bookmark name and make it less verbose. Just scroll down the list of bookmarks in that wide folder until you see the culprit, then right-click that bookmark and open Properties & edit the Name line at the top of that dialog.

  • HT5312 i didn't give a rescue email address when i first made my account and now i can't figure out how to make one

    i didnt make a rescue email address straight away and now i cant figure out how to make one

    There are instructions for how to do edit or delete it (and you can add one via the same process) half-way down the page that you posted from :
    You can edit or delete your rescue email address using the Apple ID website. To edit your rescue email address:
    Navigate to appleid.apple.com using your web browser.
    Click "Manage your account"
    When prompted, sign in using your Apple ID and password.
    Click Password & Security
    You'll be asked to answer 2 of your 3 security questions before you can make any modifications. If you are unable to remember your answers, you can choose to send an email to your rescue email to reset your security questions.
    After you've validated your identity by correctly answering your security questions, click Edit to the right of your rescue email address.
    Once you've finished editing your rescue email address, click the Save button directly below the email field.

  • After uploading IOS7, all text turned white and is very hard to see.  I can't figure out how to make the text black again.

    After loading IOS7, text turned white.  Very hard to read. Cant figure out how to make it black again.  Thanks for any help.

    chflags -R nohidden /path/to/folder/

Maybe you are looking for

  • How to handle oas parameter in the URL

    Hi, I am very curious about the oas parameter in the next URL how to form the value: OA_HTML/OA.jsp?_rc=<..._LAYOUT>&_ri=275&addBreadCrumb=RS&<...Id>=<param_value>&_ti=2094430068&oapc=3&oas=l305LKdSwzg9iJqy8q00ew.. If I use String createURL() or setF

  • Help with a list of PrintStreams! Again :D

    So basically im creating a list of PrintStreams and would then like to println something to all of them at once. What I have doesent work because my new PrintStream wont accept a printstream from the list :/ Not sure what to do. Help GREATLY apprecia

  • HT1766 icloud backup

    If i back up my iphone and then i had to restore it, how do i reach the backup

  • My iMac can't find my panasonic camera

    When I hook up my panasonic Mini DV palmcorder from the "to PC" port on the camera to my iMac thru the USB port, IMovie tells me to hook up the camera.  Camera is hooked up and playing a video.

  • HT1933 I did not purchase app

    Hello. I downloaded TomCat 2 for my kids ages 2 and 3 just this week. They are not capable of putting in my password and I only have the free version with no coins. I just got a receipt for $25.99 in purchases with this app that I did not purchase. W