Print Page | Close Window

Script Object and bytecode loader

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 Oct 2019 at 4:21am
Software Version: Web Wiz Forums 11.10 -

Topic: Script Object and bytecode loader
Posted By: bulk88
Subject: Script Object and bytecode loader
Date Posted: 23 Apr 2014 at 3:54pm
Ever wondered how the JSByteCodeWin.bin binary blob bytecode file works?  Here is some undocumented code explaining how to create and load bytecode. Run it in Acrobat's JS Console. It is not in the same format as JSByteCodeWin.bin. JSByteCodeWin.bin looks like 2 bytes per character UTF16, the string returned by freeze() has normal looking words in it. Loading from disk is a separate API and is not part of Script class so you have to figure out yourself how to get it into a JS string.  The output of freeze() is probably unique to build of Acrobat, so you cant use it to obfuscate code.

    this.level1 = new Object();
    delete this.level1.testcomp;
    s = new Script();
    s.compile("this.level1.testcomp = function () {return \"retval\";}");
    t = new Script();
    app.alert("toSource is "+t.toSource());
    app.alert("testcomp is "+this.level1.testcomp);
    app.alert("testcomp is "+this.level1.testcomp);

Posted By: try67
Date Posted: 23 Apr 2014 at 5:40pm
Interesting stuff... Thanks!

- Acrobat Expert - Contact me personally at
Check out my custom-made scripts website:

Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 -
Copyright ©2001-2017 Web Wiz Ltd. -