4 Replies Latest reply on Feb 1, 2017 4:23 AM by Trickycad2

    JPG to Multi-Page PDF Script

    Trickycad2

      Hi all,

      I'm racking my brain trying to figure out how to create a single multi-page PDF file from a folder of JPGs..

      File\Automate\PDF Presentation requires you to select files manually, which means it can't be made an action (as it remembers the file names in the action). I have tried using ScriptListener with this to get the coding, but can't figure it out, as it also contains the file names.

       

      Can any kind soul point help me with scripting that would allow me to select a folder of images and output to a multi-page PDF?

       

      Any help would be greatly appreciated!! I'm using CS6.

       

      Thanks!

      Jennifer

        • 1. Re: JPG to Multi-Page PDF Script
          Chuck Uebele Adobe Community Professional & MVP

          This is a function I used in one of my scripts to make pdf's prrofs. In the loop on line 8, proof list is a list of files from a folder that the user selects.

           

          function makePDF(){
          
          try{
                var idPDFExport = stringIDToTypeID( "PDFExport" );
                    var desc1 = new ActionDescriptor();
                    var idflst = charIDToTypeID( "flst" );
                        var list1 = new ActionList();
                        for(var i=0;i<pdfProofList.length;i++){
                              list1.putPath( new File(pdfProofList[i] ) );                    
                              }
                    desc1.putList( idflst, list1 );
                    var idT = charIDToTypeID( "T   " );
                    desc1.putPath( idT, new File(proofFolder + "/" + proofName + '.pdf' ) );//proofFolder is the folder selected to save the pdf
                    var idBckC = charIDToTypeID( "BckC" );
                    var idBckC = charIDToTypeID( "BckC" );
                    var idWht = charIDToTypeID( "Wht " );
                    desc1.putEnumerated( idBckC, idBckC, idWht );
                    var idAs = charIDToTypeID( "As  " );
                        var desc2 = new ActionDescriptor();
                        var idpdfPresetFilename = stringIDToTypeID( "pdfPresetFilename" );
                        desc2.putString( idpdfPresetFilename, """High Quality Print""" );
                        var idpdfPreserveEditing = stringIDToTypeID( "pdfPreserveEditing" );
                        desc2.putBoolean( idpdfPreserveEditing, false );
                        var idpdfCompressionType = stringIDToTypeID( "pdfCompressionType" );
                        desc2.putInteger( idpdfCompressionType, 7 );
                    var idPhtP = charIDToTypeID( "PhtP" );
                    desc1.putObject( idAs, idPhtP, desc2 );
                executeAction( idPDFExport, desc1, DialogModes.NO );
                }
          catch(e){}   
          } 
          
          • 2. Re: JPG to Multi-Page PDF Script
            Trickycad2 Level 1

            Thanks so much for the super quick response Chuck!

             

            I'm still trying to wrap my head around scripting. Usually I'm able to eventually figure things out when I see a script in action and can cobble something together. I'm assuming this function is part of a larger script? I can't seem to make this work as is, and Photoshop is saying it is missing braces LOL! Are you able to provide any guidance?

             

            Thanks,

            Jennifer

            • 3. Re: JPG to Multi-Page PDF Script
              Chuck Uebele Adobe Community Professional & MVP

              Yes, it is from a larger script: some 7,400 lines of code. It looks like I forgot the ending brace to the function. I'll edit my original post.

              • 4. Re: JPG to Multi-Page PDF Script
                Trickycad2 Level 1

                Thanks Chuck.

                I will try this and let you know!

                 

                Jennifer