Ask a Question related to Adobe Acrobat Windows, Design and Development.
-
Garrett_Cobarr@adobeforums.com #1
Where to put Javascript StartUp scripts?
I thought I knew JavaScript and I thought I knew Acrobat but I am still conceptually spazzed frequently, when I try and figure where certain scripts should live in a PDF.
I am trying to place a startup/initializing script in my PDF project. And I am not quite sure where it should be located so that it can be triggered by the opening of the doc. It needs to happen before anything else executes. So I thought, according to documentation, that this script should go in the Document Level Scripts.
I can't have any folder scripts because this project has to stand and live on its own, with the exception of Adobe Reader 6 or Acrobat 6 to run it. All script control must live in the doc.
I have the code itself figured out but the placement and trigger location has got me stumped. I had planned to trigger the script with an Event Object, event type Doc/Open. This would be targeted at my doc to avoid other Doc/Opens from triggering it. There is a mirror script that reverses the startup script's behavior on the event trigger Doc/WillClose.
I get that document wide scripts need to be at the doc level so that they can affect and be accessed from the whole project but do all scripts at the document level have to be named functions? Can you have scripts at the document level that are unnamed statements? Is this what Adobe means, on page 208 of the Acrobat JavaScript Scripting Reference , when they say,
"When a document is opened, the document level script functions are scanned
and any exposed scripts are executed."
What are exposed scripts?
I know I need to put my getUserPrefState at the document level but where do I put the event trigger? Since getUserPrefState needs to be triggered by the outside call doc.open where does that go? The Document Level Script Dialog Box seems to require named functions.
I have seen in some other people's projects that have put these kind of scripts at the page level, on the first page and trigger it with a page.open. This is impractical for a doc that needs its first page and it can be a rough visual opening for the user since the dependent setup takes place after the first page is already visible.
I am at a loss in understanding a lot of Acrobat's internal message passing scheme. I get the feeling that I am missing something really obvious.
So would someone please illuminate this poor soul to what is probably right in front of my face?
Garrett_Cobarr@adobeforums.com Guest
-
Include javascript in a javascript file
Hello, Is there a way to include a javascript file from WITHIN a javascript file? Something similar as in the "#include" directive in C++? ... -
CS: Scripts do not appear in Scripts menu
I have several utility AppleScripts that I created for Illustrator 10. I'd like to use these in CS, and they work correctly when I choose "Browse"... -
PS CS - Javascript Error on Scripts > Layer Comps to PDF?
Joe, Did you ever get a fix for this? I have just hit the same problem, when I try to run Dr Browns Image processor script...'javascript plug-in... -
need javascript staff (anyone who knows javascript peroid) (READ)
hey its me ultimategamerx and im back in some clothes lol i need some people who know java script i need help please reply if ya know some -
scripts that control other scripts
Is there any behaviour script that when attached to a sprite can control the functionality of any other scripts attached to that sprite? I want to... -
George_Johnson@adobeforums.com #2
Re: Where to put Javascript StartUp scripts?
When you create a document-level JavaScript, it provides you a function skeleton by default. You can place code within one or more function definitions, or outside of a function definition. Code that is outside of a function definition is executed when the document open, which is what you want. Functions are read into memory and are available to be called by code. Be aware that the order of loading document-level JavaScripts is undefined. This means that if you have code that depends on other code (another function, for example, be sure to place it physically after the code it depends on.
George
George_Johnson@adobeforums.com Guest
-
Garrett_Cobarr@adobeforums.com #3
Re: Where to put Javascript StartUp scripts?
Thanks George, that straightens me out.
I find the Acrobat interface confusing with so many different JavaScript windows. They need to bring it all into one, clearly labeled, JavaScript editor-debugger. Access to objects and widget's, pages, doc, and app scripts should be in one structured window so that you can see their relationship with one another and be able to get at their scripts from one window.
"Code that is outside of a function definition is executed when the document
open,"
Is that what the phrase exposed scripts means?
We're you saying in the end of your response that the document scripts are read into memory in the order they appear from the top to the bottom of the document level script window?
And thanks, again.
Garrett_Cobarr@adobeforums.com Guest
-
George_Johnson@adobeforums.com #4
Re: Where to put Javascript StartUp scripts?
We're you saying in the end of your response that the document scripts
are read into memory in the order they appear from the top to the bottom
of the document level script window?
I was trying to avoid saying that, since Adobe has never officially said that. It turns out that they are loaded in alphabetical order (in every JavaScript-capable version of Acrobat so far), but I suppose it could change in the future, so don't depend on it.
Is that what the phrase exposed scripts means?
Maybe. I'm not aware of that being a common or precise term.
George
George_Johnson@adobeforums.com Guest
-
Garrett_Cobarr@adobeforums.com #5
Re: Where to put Javascript StartUp scripts?
I would not have guessed alphabetical.
So that means un-named scrips are dealt with the order it is encountered and then the named functions in order of alphabet?
Garrett_Cobarr@adobeforums.com Guest
-
George_Johnson@adobeforums.com #6
Re: Where to put Javascript StartUp scripts?
No, I didn't say that functions are loaded in alphabetical order. Rather, document-level JavaScripts are loaded in alphabetical order. A document-level JavaScript can have zero or more functions and zero or more lines of code outside of functions. As each document-level JavaScript is loaded, the code is dealt with in the order it is encountered.
George
George_Johnson@adobeforums.com Guest



Reply With Quote

