These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Pre-compile scripts possible?

Mercurion
Registered: Feb 13 2010
Posts: 2
Answered

I have a script that's placed in the javascript folder.

In the online Acrobat SDK I read the following:

[i]When Acrobat is installed on your machine, it provides you with several standard folder level JavaScript files, [b]including JSByteCodeWin.bin[/b] (this file is a [b]pre-compiled script[/b] that supports the forms and annotation plug-ins) and debugger.js; these are in the App folder. Other JavaScript files in the App folder may be installed by third-party Acrobat plug-in developers.[/i]

It seems that not only .js files can be used but also .bin files. How can I create a .bin file myself.

I know plug-in's are usually written in c++ but since it's located in the javascript folder I assume that the scripts in this folder must be written in javascript.

Looking around, with Mr Googles help, I find a lot of javascript to exe tools but this is not what I need.

So ... can I create such a .bin file?

Luc

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
No, it's not possible. The JSByteCodeWin.bin file is a special case because it's so large,.

Acrobat will only read plain-text .JS files added by the user into the Javascripts folder. It will ignore all other files, including the JSXBIN format exported from ExtendScript Toolkit.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The above is correct, but all folder level scripts are read, interpreted and converted into code tokens so the folder level functions are not fully reprocessed each time they are called. So after Reader/Acrobat is initialized all of the folder level scripts have been 'compiled' but only to the code token stage. And this why Reader/Acrobat takes longer to initialize as more folder level scripts are added. But there is no easy way to compile document level JS code. Even Adobe still distributes the debugging console code as a JS file.

George Kaiser

Mercurion
Registered: Feb 13 2010
Posts: 2
Thanks for the quick answers.

It's not a big issue for me but it would be great to 'obfuscate' the code in my scripts. Not to protect my code from being copied but to prevent the user to modify it and [i]break it[/i].

For now I settle with [i]obfuscating[/i] the code:

this:
var a="Hello Acrobat Users!";function MsgBox(msg){alert(msg+"\n"+a);}MsgBox("OK");

becomes this:

var _0xf0a4=["\x48\x65\x6C\x6C\x6F\x20\x41\x63\x72\x6F\x62\x61\x74\x20\x55\x73\x65\x72\x73\x21","\x0A","\x4F\x4B"];var a=_0xf0a4[0];function MsgBox(_0x1ef2x3){alert(_0x1ef2x3+_0xf0a4[1]+a);} ;MsgBox(_0xf0a4[2]);
That should be enough to discourage users to modify the code. Yes, I know it's reversable but for now, it will do. Of course I keep the original source code for future revisions.

My c++ skills are rusty (actually that's an understatement) but I will look into creating a plug-in for some of my future projects. Or maybe investigate in using IAC.

Anyway, thanks for the replies.

Luc