Skip navigation
hopgal
Currently Being Moderated

Why is Doc.closeDoc causing memory reference error?

May 24, 2012 7:22 AM

Tags: #error #memory #script #javascript #livecycle #reader #acrobat_9_pro #livecycle_designer

My script worked fine when I tested it with Adobe Pro.  It is only in Adobe Reader X that it crashes and closes the app.

 

In LiveCycle ES version 8.2, I added JavaScript to do the following in the preSubmit event of a hidden Submit button:

 

var currentDoc = event.target;

var path = currentDoc.path;

execMenuItem("SaveAs",currentDoc);

var newPath = currentDoc.path;

if (path != newPath){

     //re-open the original document (blank form)

     app.openDoc({cPath:path});

}

//stop the submit event

xfa.event.cancelAction = true;

//close the current document (completed form)

if (currentDoc.disclosed = true){

   currentDoc.closeDoc();

}

 

From the JavaScript API documentation, I learned that the document has to have the disclosed property set to true to be available to other open documents.  I am doing this by calling a document-level function in the form1.docReady event, which I have verified is running when the document opens.  The original document is being opened, the saved document is being closed, but when the "Submit Cancelled" dialog box appears and I click "OK", I get this error:

 

The instruction at "0xsomething" references memory at "0x00000010".  The instruction could not be "read".

 

And whether I hit "Cancel" or "OK", the reader closes.  If I comment out the cancelAction, the same thing happens, only without the Submit Cancelled dialog.  So it must be the Doc.closeDoc that is doing it.  I have also tried putting the code in the postSubmit and setting a timeout, but in those cases the close never happened at all. 

 
Replies
  • Currently Being Moderated
    May 24, 2012 10:14 AM   in reply to hopgal

    Have you checked the Acrobat JS API Reference?

     

    Reader does not have all the same rights or methods available to Acrobat.

     

    If the PDF has been changed and you try to save the PDF will have to save rights. This is not normally amiable to Reader. You have to add special rights to the PDF with Acrobat.

     
    |
    Mark as:
  • George Johnson
    9,228 posts
    Aug 11, 2002
    Currently Being Moderated
    May 24, 2012 10:48 AM   in reply to hopgal

    The following line:

     

    if (currentDoc.disclosed = true){

     

     

    Should be changed to:

     

    if (currentDoc.disclosed == true){

     

     

    Which is the same as:

     

    if (currentDoc.disclosed) {

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points