0

I've written some custom scripts for Adobe Acrobat Pro (I work with a lot of PDFs for scientific research) and they run just fine on Mac and Windows. Linux only has Adobe Reader, but I still managed to get the menu items displaying within the file menu at startup, as shown in the screenshot of the Readme file at https://github.com/lmmx/CropScience (on Windows).

Since there is no mention of Linux in the Acrobat docs (presumably since only Reader is available rather than full Acrobat) I'm a little at a loss where to put my files to allow them the adequate permissions to run (when clicked).

A sample script, "CropPrintNature.js" corresponding to the settings for academic journal Nature:

app.addMenuItem({cName:"Crop for Nature (articles and ed.)",cParent:"Crop and Print", cExec:"for(var p=0;p<n();p++){o=a().getPageBox('BBox',p);o[0]+=34;o[1]-=37;o[2]-=33;o[3]+=22;if(p==0){o[1]-=38}for(b=0;b<4;b++){a().setPageBoxes(d[b],p,p,o)}};this.print();"});

I moved them from /opt/Adobe/Reader9/Reader/Javascripts to ~/.adobe/Acrobat/9.0/Javascripts and still doesn't work (but I think this should be the right location since it's user-specific not system-wide.

Within this latter folder, glob.js is empty and glob.settings.js just contains ��({})

I'd take a guess that there isn't any TypeError - I can see the Crop and Print button which should correspond to a cParent element referenced on clicking one of the buttons - rather there's an attempt to access something outside of its level of privilege as the last message (which logs to console when a button is clicked).

Do I need to move them, or add some config file...? The end of the console log is as follows:

App.addMenuItem:1:Folder-Level:User:CropPrintAnnuRev.js
 ===> Parameter cParent.
TypeError: Invalid argument type.
App.addMenuItem:1:Folder-Level:User:CropPrintBriefBioinfo.js
 ===> Parameter cParent.
TypeError: Invalid argument type.
App.addMenuItem:1:Folder-Level:User:CropPrintJMolBioEarly.js
 ===> Parameter cParent.
TypeError: Invalid argument type.
App.addMenuItem:1:Folder-Level:User:CropPrintAAutoBoundaries.js
 ===> Parameter cParent.
NotAllowedError: Security settings prevent access to this property or method.
Doc.setPageBoxes:1:Menu Crop for Nature Rev. Mol. Cell. Bio.:Exec

1 Answer 1

0

The cParent you have specified is not a menu item in Acrobat/Reader. You have to specify a valid menu item.

Also, you may check in the Acrobat JavaScript documentation whether setPageBoxes is available for Reader (assuming you have run the script in Reader).

2
  • I understand that, but I incorporated a script to add said cParent item below the File menu with app.addSubMenu and it works as expected on Windows/Mac. That's why I pointed out the final error message, I think it's actually a problem with security settings(?) Commented Jul 4, 2014 at 11:16
  • I just noticed Linux file system seems to ignore the space, but changing this file to AAAddMenu.js to ensure it runs first doesn't change things. The menu item shows, but still NotAllowedError: Security settings prevent access to this property or method. Doc.setPageBoxes:1:Menu Crop for BMC:Exec when a journal button is clicked. Commented Jul 4, 2014 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .