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

saveas or docclose: acrobat crashes after warning re executing app:init script

martinabccunningham
Registered: Oct 12 2010
Posts: 3

I am trying to build a utility that will
(a) open a connection to a one-table database;
(b) loop through all the rows of data, performing the following on each row:
(i) store a column of data into a variable called 'controlID'
(ii) open a document called 'source.pdf',
(iii) write a footer into 'source.pdf' containing 'controlID'
(iv) save 'source.pdf' as '[controlID].pdf' to a different directory
(v) close '[controlID].pdf'
 
I had no problem getting the database part working, but am running into a stubborn error when attempting to invoke either 'saveAs' or 'closeDoc'. Setting the database stuff to the side, I wrote the following one-line script to troubleshoot the problem:
 
var source = app.openDoc("/C/source.pdf");
 
This causes the file to open, but if I add either or both of these:
 
source.saveAs("/C/output.pdf");
source.closeDoc(true);
 
Then a dialog box appears with the following message:
 
"Do you really want to execute the script: App:Init?
Executing it could interfere with the debugging session currently under way."
 
Clicking either 'Yes' or 'No' results in a fatal error - Acrobat crashes. I have searched for this message and can't find anyone with the same problem.
 
By the way, I associated the above script with a 'page open' action. I've also tried running it from within a separate .js file that runs every time i start up acrobat.exe and get the same result.
 
Would appreciate your help here!

My Product Information:
Acrobat Pro 9.3, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Have you looked at the documentation for the saveAs method regarding the security restrictions?

When testing, you might want to try saving to your documents folder, as opposed to the root directory, which should not be allowed.
martinabccunningham
Registered: Oct 12 2010
Posts: 3
Looking into security restrictions now - thanks. I noted from reading posts of others who were having trouble with 'saveas' that they were getting a different error message which is why I didn't explore this.

I used the root directory for illustration purposes. The actual path of the source doc is deep in my my documents folder, and the same error is occurring.
martinabccunningham
Registered: Oct 12 2010
Posts: 3
OK I learned about trusted functions from the SDK and created trusted versions of saveAs and closeDoc which i have successfully tested. Leaving that to the side for the moment, I find I'm getting the fatal error at an even more basic level.

I placed the following folder-level function into 'test.js', located in my user javascripts folder:

function myFunction()
{
println("Hello, world!")
};

After re-starting Acrobat, I open up the console, type "myFunction()" into it and hit CTRL+ENTER. The result is the same message as describe earlier followed by Acrobat crashing. I have also tried defining "myFunction" as a trusted function and got the same result. is it possible to call a function from within the console? I was hoping it was.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Yes, it's perfectly fine to call a function from the console. I have never seen that error message before. I'll look into it a bit more