Quantcast
Channel: Adobe Community : All Content - All Communities
Viewing all articles
Browse latest Browse all 290743

Why do I have to run a doc.saveAs() prior to Inserting, Deleteing, or Extracting pages?

$
0
0

MY SETUP:

I'm using folder level javascripts.   In Acrobat I have the 'enable menue items javascript execution privledge' enabled,  In my actual folder level scrips I have them wrapped in a trusted function along with app.beginPriv()/app.endPriv().    My PDF's are coming from LiveCycle Designer which I then open and run in Acrobat.

 

MY QUESTION:

Through much trial and error and banging my head on the wall I've found that if I want to use insertPages(), extractPages() or deletePages() called as a trusted fucntion  on its own it won't work unless I first run a saveAs() function to create a new document file and only then can I run the desired function on the new saveAs'd doc.   I simply can't run an insertPages() on the current open doc without a saveAs first().    

 

Why is that?

 

I find that very frusterating and the resulting errors aren't a help.  If I don't SaveAs first I get security error or invalid function errors.

 

 

EXAMPLE:

Save As Function:

var LCB_SaveAs = app.trustedFunction(function(doc, filename) {

    app.beginPriv();

    doc.saveAs(filename);

    app.endPriv();

});

 

Insert Page Function:

var TEST_InsertPage = app.trustedFunction(function(doc, filename) {

    app.beginPriv();

       doc.insertPages ({

           nPage: -1,

           cPath: filename

       });

       app.endPriv();

});

 

 

Javascript code in document to call the above functions:

if(typeof(LCB_SaveAs) == "function") {

    if(typeof(TEST_InsertPage) == "function") {

        try {

            TempFileLocation = "/C/PATH/InsertTemp.pdf"

            LCB_SaveAs(event.target, TempFileLocation);

            try {

                PathOfInsertDoc = "/C/PATH/FileToInsertIntoSaveAs'dDoc.pdf"

                TEST_InsertPage(event.target, PathOfInsertDoc)

            }

            catch(e) {

                xfa.host.messageBox(e.toString().replace("RaiseError: ","") , 0, 0); 

            }

        }

        catch(e) {

            xfa.host.messageBox(e.toString().replace("RaiseError: ",""), 0, 0); 

        }

    }

}


Viewing all articles
Browse latest Browse all 290743

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>