Jump to content

Preview and Javascript Functions


RickG

Recommended Posts

Hi All,

 

Due to a complicated rule set for a project, I'm writing a rather large global javascript function. When I attempt to preview the template, with the Preview checkbox on, the first record displays fine, but when attempting to navigate to the next record the CPU goes to 100% and eventually an error comes up stating that "FP has encountered a fatal error and must abort" and states that I need to restart Acrobat.

 

The following is appearing the Security event log:

 

Code Integrity determined that the page hashes of an image file are not valid. The file could be improperly signed without page hashes or corrupt due to unauthorized modification. The invalid hashes could indicate a potential disk device error.

File Name:    \Device\HarddiskVolume2\Windows\System32\l3codeca.acm    

I've run some disk utils on the drive was unable to find and disk errors.

 

Going under the assumption that I have some issue with my JS, I'm commenting out large chunks of code but the issue continues. I've also removed any reference to the global function in the text frames, but the problem continues.

 

My question is, when FP is doing its preview routine, is it attempting to run all JS routines regardless if they are referenced or not. Additionally, will FP still inspect commented out chucks of code making the approach to comment out code useless?

 

Thank you in advance,

Rick

Link to comment
Share on other sites

Ugh...found the issue...and the answer to my question.

 

Issue: If you have a routine in a while-loop and change the function being called to add a parameter...it helps to actually pass the parameter to the function. Wish the validator caught that, although I expect that JS allows the omission of a parameter and just accepts it as null.

 

To answer the actual question, yes, it appears that the JS functions are "run" even if they are never being called from within any text frame.

 

Thanks,

Rick

Link to comment
Share on other sites

Due to a complicated rule set for a project, I'm writing a rather large global javascript function. When I attempt to preview the template, with the Preview checkbox on, the first record displays fine, but when attempting to navigate to the next record the CPU goes to 100% and eventually an error comes up stating that "FP has encountered a fatal error and must abort" and states that I need to restart Acrobat.

We do want to investigate and fix that crash. So, please collect up the job, or at least a minimal example which reproduces the crash, and either post it here or send it to FusionProSupport@PTI.com with a note to bring it to my attention. Or at least post the code. Also, please include the specific versions of Acrobat, FusionPro, and your operating system.

The following is appearing the Security event log:

Code Integrity determined that the page hashes of an image file are not valid. The file could be improperly signed without page hashes or corrupt due to unauthorized modification. The invalid hashes could indicate a potential disk device error.

File Name:    \Device\HarddiskVolume2\Windows\System32\l3codeca.acm    

I've run some disk utils on the drive was unable to find and disk errors.

I don't think that has anything to do with the crash in Acrobat.

My question is, when FP is doing its preview routine, is it attempting to run all JS routines regardless if they are referenced or not.

Yes. Well, mostly yes. It kind of depends on what you mean by "routines."

 

If you mean rules themselves, then every "regular" JavaScript rule is executed automatically once per record (where a Preview is a single-record composition). Other Callback rules are executed as required. Some rules may also be executed multiple times if they're called out from other rules with the Rule function.

 

As for functions (declared with the "function" keyword in JavaScript), those are only run when they're actually called. Although usually if you declare a function, you're probably calling it from within a rule which is going to be run.

Additionally, will FP still inspect commented out chucks of code making the approach to comment out code useless?

No, commented code (or anything in comments, for that matter) is completely ignored by the JavaScript interpreter.

Issue: If you have a routine in a while-loop and change the function being called to add a parameter...it helps to actually pass the parameter to the function. Wish the validator caught that, although I expect that JS allows the omission of a parameter and just accepts it as null.

Yes, all arguments in JavaScript functions defined in JavaScript code are optional, and will be set to undefined in the function if not passed. This is just the way JavaScript works, since it's an interpreted language. (This is not always true of JavaScript functions declared in C code, such as many of the built-in functions in FusionPro. So if you call, say, Field() with no arguments, you'll get an exception about needing more arguments.)

 

The other thing is, even if you code an infinite loop, that should still be detected and handled somewhat gracefully (i.e. without crashing Acrobat). For instance, if I do this in a rule:

while (true) {}

It throws an "Execution limit exceeded" error.

 

However, you seem to have triggered some other behavior which is causing a crash, and we do want to fix that. So, please post the job as I mentioned.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...