12 Replies Latest reply on Jun 6, 2014 12:11 AM by s_ashok

    generating package from indesign

    bacas_christy Level 1

      Hi,

       

      As we know there is an option in indesing for generating package for a file (File--->package).

       

      Getting package is one of the part of my script i need to do for automation.

       

      I searched for package option in javascript. I didnt get anything.

       

      If u have any idea or solution please share with me.

       

       

      Thanks and regards

       

      Christy

        • 1. Re: generating package from indesign
          milligramme Level 3

          Hi

          This code below is works for me. InDesign CS4.

           

           

          var to = new File("~/Desktop/package_folder/");
          var flag = Folder(to).create();
          
          var copyingFonts = true;
          var copyingLinkedGraphics = true;
          var copyingProfiles = true;
          var updatingGraphics = true;
          var includingHiddenLayers = true;
          var ignorePreflightErrors = true;
          var creatingReport = true;
          var versionComments = "comment";
          var forceSave = true;
          
          if ( flag === true){
              app.activeDocument.packageForPrint (
                    to, 
                    copyingFonts, 
                    copyingLinkedGraphics, 
                    copyingProfiles, 
                    updatingGraphics, 
                    includingHiddenLayers,
                    ignorePreflightErrors, 
                    creatingReport, 
                    versionComments,
                    forceSave
                   );
          }
          
          
          
          1 person found this helpful
          • 2. Re: generating package from indesign
            siva k Level 1

            Hello milligramme,

             

            Your script is working well. Is it possible to add to your script export pdf, before creating package (for InDesign CS3)..?

             

            Thanks in Advance.

             

            Regards,

            Siva

            • 3. Re: generating package from indesign
              milligramme Level 3

              Hello Siva

               

              To export PDF with minimal argument

               

              doc.exportFile (ExportFormat.PDF_TYPE, [File]);

               

              this will export all pages with the document's current PDF Export Preset.

               

              try more arguments

              [, showingOptions, pdfExportPreset, withGrids, versionComments, forceSave]

               

              and to controll pdf export options see those properties

              app.pdfExportPreferences
              app.pdfExportPresets

               

              thanks,

              mg

              • 4. Re: generating package from indesign
                siva k Level 1

                 

                Hi milligramme,

                 

                Thanks for your replay and script; if you don’t mind please post total script at a time. When I was running script some errors are showing on my screen. And one more thing package folder can passed for choose to specific path instead of DESKTOP….? Folder name will be file name. If you post total script with these small changes it’s very very helpful for my daily tasks. Please please please post for me again.

                 

                Thanks in advance.


                Regards,
                Siva


                • 5. Re: generating package from indesign
                  milligramme Level 3

                  Adjust this script to your environment. This script has minimum function.

                   

                  /**
                   *  export pdf and package indd
                   * 
                   * Run for saved and validated document(s) 
                   * choose folder to save pdf and packaged items
                   * pdf is contain package folder (named with document name)
                   *  
                   *  Created by mg on 2010-09-29.
                   */
                  (function () {
                       if(app.documents.length === 0){
                            exit();
                       }
                       var docObj = app.documents;//has many
                       //set folder distination, creat folder for each documents
                       dirFolder = Folder.selectDialog ( "choose folder for saving package folder" );
                       if(dirFolder === null){
                            exit(); //cancel process
                       }
                       else{ //dirFolder is choosen
                            for (var i= docObj.length - 1; i >= 0; i--) { //loop 
                                 var pdfExPreset = undefined;//app.pdfPresets.item("[高品質印刷]");
                                 dir = new File( dirFolder + "/" + decodeURI(docObj[i].name) + "/" );
                                 flg_dir = new Folder (dir).create();
                                 if ( flg_dir === true){
                                      exportPDF ( dir, docObj[i], pdfExPreset );
                                      createPackage ( dir, docObj[i] );
                                 }//if
                                 
                                 //to close document without saving use below
                                 //docObj[i].close(SaveOptions.NO);
                                 
                            }//for doc
                       }//else
                  })();
                  
                  /**
                   * export pdf
                   * 
                   * @param {Object} dir Folder to Export
                   * @param {Document} doc Document
                   * @param {Object} pdfExPreset PDF Export Preset
                   */
                  function exportPDF( dir, doc, pdfExPreset ){
                       var pdfName = File ( dir + "/" + doc.name.replace(/($|\.indd$)/,".pdf") );
                       var showingOptions = false;
                       var pdfExportPreset = pdfExPreset;
                       var withGrids = false
                       var versionComments = "";
                       var forceSave = false;
                       
                       doc.exportFile ( 
                            ExportFormat.PDF_TYPE, 
                            pdfName, 
                            showingOptions, 
                            pdfExportPreset, 
                            withGrids, 
                            versionComments, 
                            forceSave
                            );
                  }
                  /**
                   * create package
                   * 
                   * @param {Object} dir Folder to Export
                   * @param {Document} doc Document
                   */
                  function createPackage( dir, doc ){
                       var to = dir;
                  
                       var copyingFonts = true;
                       var copyingLinkedGraphics = true;
                       var copyingProfiles = true;
                       var updatingGraphics = true;
                       var includingHiddenLayers = false;
                       var ignorePreflightErrors = true;
                       var creatingReport = true;
                       var versionComments = "";
                       var forceSave = false;
                  
                       app.activeDocument.packageForPrint (
                            to, 
                            copyingFonts, 
                            copyingLinkedGraphics, 
                            copyingProfiles, 
                            updatingGraphics, 
                            includingHiddenLayers,
                            ignorePreflightErrors, 
                            creatingReport, 
                            versionComments,
                            forceSave
                            );
                  }
                  
                  • 6. Re: generating package from indesign
                    siva k Level 1

                     

                    Hello Milligramme,

                     

                    Thanks for your replay and maximum efforts on this script. I tried this script sorry to say this it’s saying an error on ‘Line no 52’ and I don’t have any scripting knowledge to resolve the error. If you don’t mind please resolve the problem and pdf creation would be already defined job settings (MagazineAds_1v3(Ads)). Or pass to choose the pdf presents as you like. Please don’t think I am asking too much. Please please post for me again…!!!

                     

                    More information: I am using In Design CS3 in Windows 7

                     

                    If you required please find out the attached file for pdf presents settings for In Design.

                     

                    https://docs.google.com/leaf?id=0B9xW8NbA0IdJNzBmYzk1N2YtNGZjOC00ZTc5LTk2ODMtZGNhZTBlMmIxY WMz&hl=en&authkey=CPTM2LgB

                     

                    Thanks in advance.

                     


                    Regards,

                    Siva

                    • 7. Re: generating package from indesign
                      milligramme Level 3

                      Hi Siva

                      Sorry, I mistook pdf preset property name, "pdfExportPresets" is correct.

                      After replacing the snippet below, the code will run.

                       

                      var pdfExPreset = app.pdfExportPresets.item( "MagazineAds_1v3(Ads)" );
                      

                       

                       

                      Regard

                      mg

                      • 8. Re: generating package from indesign
                        siva k Level 1

                         

                        Hi Milligramme,

                         

                        Thanks for your replay. I tried your script I strongly believe I am doing some thing wrong in replacing your last post. I tried so many times. But no use if you don’t mind can you please post me all final script for last time. Please try in your system before posting here. I hope you are understudied my problem…


                        Thanks in Advance.


                        Regards,
                        Siva

                        • 9. Re: generating package from indesign
                          siva k Level 1

                           

                           

                          Any one fixes this problem...

                          • 10. Re: generating package from indesign
                            milligramme Level 3

                            includingHiddenLayers is argument for CS4,

                            here is whole script.  it works on my OSX 10.6 + InDesign CS3.

                             

                            /**
                             *  export pdf and package indd
                             * 
                             * Run for saved and validated document(s) 
                             * choose folder to save pdf and packaged items
                             * pdf is contain package folder (named with document name)
                             *  
                             *  Created by mg on 2010-09-29.
                             */
                            (function () {
                                 if(app.documents.length === 0){
                                      exit();
                                 }
                                 var docObj = app.documents;//has many
                                 //set folder distination, creat folder for each documents
                                 dirFolder = Folder.selectDialog ( "choose folder for saving package folder" );
                                 if(dirFolder === null){
                                      exit(); //cancel process
                                 }
                                 else{ //dirFolder is choosen
                                      for (var i= docObj.length - 1; i >= 0; i--) { //loop 
                                           var pdfExPreset = undefined;//app.pdfExportPresets.item("MagazineAds_1v3(Ads)");
                                           dir = new File( dirFolder + "/" + decodeURI(docObj[i].name) + "/" );
                                           flg_dir = new Folder (dir).create();
                                           if ( flg_dir === true){
                                                exportPDF ( dir, docObj[i], pdfExPreset );
                                                createPackage ( dir, docObj[i] );
                                           }//if
                                           
                                           //to close document without saving use below
                                           //docObj[i].close(SaveOptions.NO);
                                           
                                      }//for doc
                                 }//else
                            })();
                            
                            /**
                             * export pdf
                             * 
                             * @param {Object} dir Folder to Export
                             * @param {Document} doc Document
                             * @param {Object} pdfExPreset PDF Export Preset
                             */
                            function exportPDF( dir, doc, pdfExPreset ){
                                 var pdfName = File ( dir + "/" + doc.name.replace(/(\.indd$|\$)/,".pdf") );
                                 var showingOptions = false;
                                 var pdfExportPreset = pdfExPreset;
                                 var withGrids = false
                                 var versionComments = "";
                                 var forceSave = false;
                                 
                                 doc.exportFile ( 
                                      ExportFormat.PDF_TYPE, 
                                      pdfName, 
                                      showingOptions, 
                                      pdfExportPreset, 
                                      withGrids, 
                                      versionComments, 
                                      forceSave
                                      );
                            }
                            /**
                             * create package
                             * 
                             * @param {Object} dir Folder to Export
                             * @param {Document} doc Document
                             */
                            function createPackage( dir, doc ){
                                 var to = dir;
                            
                                 var copyingFonts = true;
                                 var copyingLinkedGraphics = true;
                                 var copyingProfiles = true;
                                 var updatingGraphics = true;
                                 //var includingHiddenLayers = false;
                                 var ignorePreflightErrors = true;
                                 var creatingReport = true;
                                 var versionComments = "";
                                 var forceSave = false;
                            
                                 app.activeDocument.packageForPrint (
                                      to, 
                                      copyingFonts, 
                                      copyingLinkedGraphics, 
                                      copyingProfiles, 
                                      updatingGraphics, 
                                      //includingHiddenLayers,
                                      ignorePreflightErrors, 
                                      creatingReport, 
                                      versionComments,
                                      forceSave
                                      );
                            }
                            

                            mg

                            • 11. Re: generating package from indesign
                              siva k Level 1

                              Hello milligramme,

                               

                              Thanks for your response for every time. I must say you have a great Patience . I tried your updated script in Mac OSX 10.5.8 + In Design CS3, Windows 7 + In Design CS3 same problem as previews. Other scripts are working pretty well. Here I am sending screen shot for more calefaction. Please please have a look.


                              Regards,

                              Siva

                              Error.png

                              • 12. Re: generating package from indesign
                                s_ashok Level 1

                                Hi,

                                 

                                * i unable to del the link folder

                                 

                                * i cannot move the linkfiles to the root dir (ex: where the indesign file located)

                                 

                                * can u any provided example of making zip using indesign script for windows.

                                 

                                below are scenario.

                                 

                                 

                                 

                                 

                                 

                                var myDocument = app.activeDocument;

                                 

                                var docname = myDocument.name;

                                 

                                var packagePath = myDocument.filePath+"/package/";

                                 

                                var myDocFolder = new Folder(myDocument.filePath+"/");

                                 

                                var myPackageFolder = new Folder(packagePath);

                                 

                                myPackageFolder.create();

                                 

                                myDocument.packageForPrint(myPackageFolder, false, true, false, true, true, false, false);

                                 

                                 

                                 

                                var myLinkFolder = new Folder(myPackageFolder+"/Links/");

                                 

                                var myLinkFiles = myLinkFolder.getFiles();

                                 

                                 

                                 

                                alert(myLinkFiles);

                                 

                                 

                                 

                                for(i=0; i<myLinkFiles.length; i++) { var linkfile = new File(myLinkFiles[i]); linkfile.Move(myDocFolder, true); } myPackageFolder.remove();

                                 

                                 

                                 

                                 

                                 

                                 

                                 

                                 

                                 

                                Please any help me on these.

                                 

                                thanks in advance

                                 

                                regards

                                 

                                Ashok