Quantcast
Channel: Adobe Community : Unanswered Discussions - Acrobat
Viewing all articles
Browse latest Browse all 73766

Adding Stamp Annotation fails after 1100 files

$
0
0

I'm trying to stamp 2500 PDF files by javascript. After around 1100 files had been stamped the Acrobat.exe process is terminated without any error message.

This also happens if I call AFExecuteThisScript() with an according addAnnot() javascript string from within a plugin. Please note that in the plugin I do the message handling so the Windows "not Responding" doesn't appear and that addAnnot() is the only javascript call I do from the plugin.

 

I use Acrobat Pro 11 on a Win7 64 bit.

 

Am I doing something wrong or is this a limitation of Acrobat Pro? Will this happen too if I do everything in the plugin (without any javascript call)?

 

Here are the two javascripts that reproduce this. The first one generates 2500 copies of the first active document in Acrobat,

the second one stamps them. They are independent from each other but the first one adds (n) to the filenames and the second one excpects filenames in the format filename(n).pdf for n from 0 to 2500 and the first active doc to bee filname.pdf.

 

/* Make 2500 copies of a pdf file */

/*

execution instrucions:

- create a new folder somewhere

- copy a pdf file into it

- close all open documents in Acrobat

- open the copied file in Acrobat

- execute this script in the console

- it will run for about 3 minutes

*/

var doc = app.activeDocs[0];

var fname = doc.documentFileName;

var savepath;

for(i=0; i<2500; i++){

          savepath = fname.substring(0, fname.lastIndexOf(".")) + "(" + i + ")" + fname.substring( fname.lastIndexOf("."));

          doc.saveAs(savepath);

}

 

 

/* Stamp 2500 pdf files */

/*

execution instrucions:

- save this script as a .js file in Acrobat privileged folder

- restart Acrobat

- open up the pdf file you copied (only the one without the (n) in filename!)

- execute it from Add-on Tools, "Stamp 2500 documents" entry (it won't work from the console)

*/

stampAllFiles = app.trustedFunction(function () {

          app.beginPriv();

          var doc = app.activeDocs[0];

          var docpath = doc.path;

          doc.closeDoc();

          var file;

          var fnamepadb = docpath.substring(0, docpath.lastIndexOf(".")) + "(";

          var fnamepada = ")" + docpath.substring( docpath.lastIndexOf("."));

          for(i = 0; i < 2500; i++){

                    file = fnamepadb + i + fnamepada;

                    doc = app.openDoc(file);

                    try{

                              doc.addAnnot({page: 0, type: "Stamp", name: "thestamp", rect: [256, 621, 356, 688 ], AP: "Draft"});

                              doc.saveAs(doc.path);

                    }catch(err){

                              app.alert("ERROR");

                    }

                    doc.closeDoc();

          }

          app.endPriv();

});

allFilesStamper = {

    cName: "stampAllFiles",

          cLabel: "Stamp 2500 documents",

          cExec: "stampAllFiles();",

          cEnable: "event.rc = app.doc",

    nPos: -1

};

app.addToolButton(allFilesStamper);


Viewing all articles
Browse latest Browse all 73766

Trending Articles



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