Me_Cool Me_Cool - 1 year ago 91
Javascript Question

Custom menu (Acrobat X) for action using javascript

I created an action using Action wizard in Acrobat Pro X.

A JavaScript is running when action started.

What this Javascript Do? suppose 100 page in opened pdf, this javascript extract all as seperate pages and rename it as user defined style.

e.g. Hello_001.pdf,Hello_002.pdf,Hello_003.pdf,Hello_004.pdf,... and so on,

i want a Custom Menu which target this action to execute.

Answer Source

It seems to me that you can find your answer in the link you gave. Important is that your script/function works correctly. So test it before in the js console. However here an example, where you can replace the script with yours. Regards, Reinhard

EDIT: (25.11.) Thought can use it by myself, but then I want to have it sortable. So I introduced leading zeros in the extract filename -> function changed.

//Save this in the ....\Acrobat\Javascripts\  program or user directory 
//  as whatever.js to load as Add-In

//-> create a submenu as first position under "Edit"
app.addSubMenu({ cName: "Specials", cParent: "Edit", nPos: 0 }); 

//-> now create a Menuitem for the function you will execute
app.addMenuItem({ cName: "Extract all Pages to file", cParent: "Specials", cExec: "extractAll()"}); 

//-> state your function (extract all Pages with leading zeros)
extractAll = app.trustedFunction(function (){
var re = /.*\/|\.pdf$/ig;
    var filename = this.path.replace(re,"");
    var lastPage = this.numPages;
    var lz = Math.pow(10, (lastPage).toString().length); //calc full decimals (10,100,..)
    app.beginPriv(); // Explicitly raise privilege
    for ( var i = 0;  i < lastPage; i++ ) {
        var zPgNo = (lz + i+1).toString().slice(1); //calc actual, cut leading 1 = zerofilled PgNo
            nStart: i,
            nEnd: lastPage -1,
            cPath : filename + "_page_" + zPgNo + ".pdf"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download