What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Reply to thread

Photoshop may not be the best to create PDF's Acrobat may be better. There is a forum on Adobe ...

Acrobat forum


I think I have fixed the sort problem and set the quality to maximum (10).

So this is the best I can get :slap:


Here is the new code...

[code]

#target photoshop;

app.displayDialogs = DialogModes.NO;

Array.prototype.humanSort = function() { 

  return this.sort(function(a, b) {

    aa = a.split(/(\d+)/);

    bb = b.split(/(\d+)/);


    for(var x = 0; x < Math.max(aa.length, bb.length); x++) {

      if(aa[x] != bb[x]) {

        var cmp1 = (isNaN(parseInt(aa[x],10)))? aa[x] : parseInt(aa[x],10);

        var cmp2 = (isNaN(parseInt(bb[x],10)))? bb[x] : parseInt(bb[x],10);

        if(cmp1 == undefined || cmp2 == undefined)

          return aa.length - bb.length;

        else

          return (cmp1 < cmp2) ? -1 : 1;

      }

    }

    return 0;

  });

}

var topLevel = Folder.selectDialog("Please select top level folder");

if(topLevel != null ){

var folders =[];

folders = FindAllFolders(topLevel, folders);

folders.unshift(topLevel);

alert(folders.length);

for(var z =0;z<folders.length;z++){

files = folders[z].getFiles("*.jpg");

filelist=[];

for(var f in files){ filelist.push(decodeURI(files[f])); }

filelist.humanSort();

createPresentation(folders[z]);

files=[];

filelist=[];

    }

}

function createPresentation(Dir){   

    var d = new ActionDescriptor(); 

    var list = new ActionList();  

    for(var h=1;h<filelist.length;h++) list.putPath(File(filelist[h]));     

    d.putList(stringIDToTypeID("filesList"), list);     

    d.putPath(stringIDToTypeID("to"), new File(Dir + "/" + decodeURI(Dir.name) + ".pdf"));    

    d.putBoolean(stringIDToTypeID("includeAnnotations"), true);  

    d.putEnumerated(stringIDToTypeID("backgroundColor"), stringIDToTypeID("backgroundColor"), stringIDToTypeID("white")); 

    d.putBoolean(stringIDToTypeID("autoAdvance"), true); 

    d.putInteger(stringIDToTypeID("autoAdvanceSeconds"), 5); 

    d.putBoolean(stringIDToTypeID("loop"), true); 

    d.putEnumerated(stringIDToTypeID("transition"), stringIDToTypeID("transition"), stringIDToTypeID("random")); 

    d.putBoolean(stringIDToTypeID("presentation"), true); 

    var d1 = new ActionDescriptor(); 

    d1.putString(stringIDToTypeID("pdfPresetFilename"), "High Quality Print"); 

    d1.putBoolean(stringIDToTypeID("pdfPreserveEditing"), true); 

    d1.putBoolean(stringIDToTypeID("pdfViewAfterSave"), false); 

    d1.putInteger(stringIDToTypeID("pdfCompressionType"), 10); 

    d.putObject(stringIDToTypeID("as"), stringIDToTypeID("photoshopPDFFormat"), d1); 

    executeAction(stringIDToTypeID("PDFExport"), d, DialogModes.NO);

};

function FindAllFolders( srcFolderStr, destArray) {

    var fileFolderArray = Folder( srcFolderStr ).getFiles();

    for ( var i = 0; i < fileFolderArray.length; i++ ) {

        var fileFoldObj = fileFolderArray[i];

        if ( fileFoldObj instanceof File ) {           

        } else {

         destArray.push( Folder(fileFoldObj) );

        FindAllFolders( fileFoldObj.toString(), destArray );

        }

    }

    return destArray;

}


[/code]


What is our favorite program/app? (Hint - it begins and ends with the letter P)
Back
Top