Print Page | Close Window

How to bind codes with customized menuitems?

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=42
Printed Date: 20 Sep 2019 at 10:18pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: How to bind codes with customized menuitems?
Posted By: oald
Subject: How to bind codes with customized menuitems?
Date Posted: 27 Sep 2011 at 2:43pm
I want to develop a folder level JavaScript to automate the cropping of PDF documents, I refer to "Developing Acrobat Applications Using JavaScript" and find the sample codes as below, the reference indicates that I save the codes to config.js and  place it under C:\Documents and Settings\user ID\Application Data\Adobe\Acrobat\8.0\JavaScripts:
 
app.addSubMenu({ cName: "New", cParent: "File", nPos: 0 })
app.addMenuItem({ cName: "A4", cParent: "New", cExec: "app.newDoc(420,595)"});
 
I wonder how I can replace the "app.newDoc(420,595)" in the sample code with my codes as following:
 
for (var i = this.numPages - 1; i >= 0; i--)
{
 var rCrop = this.getPageBox("Crop",i);
 rCrop[0] += 72; // Adjust Left Side
 rCrop[1] -= 72; // Adjust Top Side
 rCrop[2] -= 72; // Adjust Right Side
 rCrop[3] += 72; // Adjust Bottom Side
 this.setPageBoxes("Crop",i,i,rCrop);
}
 
Need I create a function for my codes and use the methods apply or call to execute the function? Or I need to create a separate JS file and put it under my user foler then use some method to execute it?
 
Your suggestion and guidance are really appreciated!



Replies:
Posted By: BAlheit
Date Posted: 27 Sep 2011 at 4:16pm
Put your code in a function:

function crop()
{
...
}

and use this function:

app.addMenuItem ({ ... , cExec: "crop()" });




Posted By: oald
Date Posted: 28 Sep 2011 at 9:18am
Hi BAlheit,
 
It works, thanks so much for your prompt help which is so timely!
 
Have a good day!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net