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.
Printed Date: 17 Feb 2020 at 8:34pm
Software Version: Web Wiz Forums 11.10 -

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
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!

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 -
Copyright ©2001-2017 Web Wiz Ltd. -