5 Replies Latest reply on Nov 5, 2017 5:53 PM by anthonyoe

    Export Each Alternate Layout to Separate PDF?

    Andymc7 Level 1

      Hi everyone,

       

      I really like the Alternate Layout functionality of ID CC, but find it tedious when I have to export each layout to a separate pdf. Is there an existing way to do this in a batch, or a script that would do this for me, allowing me to choose a PDF Preset also?

       

      Specs:

       

      ID CC 2017

      Win10

       

       

      Thanks in advance for any and all replies!

       

       

      -Andy

        • 1. Re: Export Each Alternate Layout to Separate PDF?
          tristanc62106920

          Hi there, i am also trying to find exactly the same answer. I designed a simple log book with 15 different versions so i used alternate layouts. Now its finalised and i just need to export them all at once. It's ok its 15 only but what if i have 80 of them !?

          • 2. Re: Export Each Alternate Layout to Separate PDF?
            jakec88782761 Level 2

            You can use the appliedAlternateLayout property of a page to decide whether you want to export it.

             

            • 3. Re: Export Each Alternate Layout to Separate PDF?
              Peter Kahrel Adobe Community Professional & MVP

              http://www.kahrel.plus.com/indesign/pdf_individuals.html

               

              This one has an option to export indd files by alternate layout, and you can select the layouts as well. Only thing is that you have to stick the files in a book file, but that's easy enough.

               

              P.

              • 4. Re: Export Each Alternate Layout to Separate PDF?
                tristanc62106920 Level 1

                Hello Guys,

                 

                I also found a script that does the job ! Here you go :

                 

                 

                Copy the below into a text file then rename it as : ExportAlternativeLayoutsAsPDF.jsx (make sure the .jsx is the extension of the file)

                 

                /*

                    Here is my solution (actually, not only mine - I found similar script and modified them to make it work the way you need).

                 

                 

                    This script ask you to choose PDF Export preset first (you can set necessary settings in:

                   

                    File > Adobe PDF Presets > Define... dialog box,

                 

                 

                    then save preset, and choose it when you run this script).

                    Once you choosed Export Preset - click OK,

                    Script will save pdf files with your alternative layouts to the same folder where your InDesign file is saved,

                    with name of FileName_LayoutName.pdf

                       

                    If you have suggestions of how to improve this code - feel free to contact me    

                    Oleh Melnyk  oleh.melnyk@gmail.com

                    5 November 2014

                */

                 

                 

                pagesCount = app.activeDocument.pages.length;

                 

                 

                alternativeLayout = []; // arrayes with alternative layouts names

                 

                 

                fileName = app.activeDocument.name;

                filePath = app.activeDocument.fullName.fsName;

                fileNameWithPath = filePath.replace(/.indd/, ""); // remove indesign .indd extenstion, as we don't need it

                 

                 

                // dirty way to get all alterative layouts names - there should be a better way, but for now I don't know how

                for(i = 0; i < pagesCount; i++)

                {   

                    if(alternativeLayout[alternativeLayout.length-1] != app.activeDocument.pages[i].appliedAlternateLayout.alternateLayout)

                    {

                        alternativeLayout.push(app.activeDocument.pages[i].appliedAlternateLayout.alternateLayout );

                    }

                }

                 

                 

                // CORE of the script from here: http://indisnip.wordpress.com/2010/08/02/simple-pdf-export-with-preset-selection/

                presets = app.pdfExportPresets.everyItem().name;

                presets.unshift("- Select PDF Preset -");

                 

                var win = new Window('dialog', 'PDF Export Presets');

                win.orientation = 'row';

                with(win){

                    win.header = add('statictext', undefined, 'Select PDF Export preset:');

                    win.PDFExport = add('dropdownlist',undefined,undefined,{items:presets});

                    win.PDFExport.selection = 0;

                    win.button = add('button', undefined, 'OK');

                    };

                win.center();

                window = win.show();

                 

                if(window == true && win.PDFExport.selection.index != 0)

                {

                    preset = app.pdfExportPresets.item(String(win.PDFExport.selection));

                 

                 

                    for(l = 0; l < alternativeLayout.length; l++)

                    {

                        app.pdfExportPreferences.pageRange = alternativeLayout[l];

                        app.activeDocument.exportFile(ExportFormat.pdfType, (new File(fileNameWithPath + "_" + alternativeLayout[l] + ".pdf")), false, preset);

                    }

                }

                else

                {

                    alert("No PDF Preset selected");

                }

                 

                 

                 

                 

                Hope it helps, this works for me !

                • 5. Re: Export Each Alternate Layout to Separate PDF?
                  anthonyoe

                  Strangely enough (or not so strange considering that this doesn't seem to be common practice), I came upon the same code that tristanc62106920 came across. I got in contact with the original author of the code and he kindly updated it to export interactive PDF files... with some extra options written in the code. Thanks to Oleh, and nice one Tristan - I didn't know enough to modify this myself.

                   

                  The key difference here is that any interactive PDF, click/hide/show/hyperlink/roll over elements are maintained. This is not possible with a normal 'print preset'.

                   

                  Same as above, copy or save into .jsx file and install into indesign. Feel free to modify the export setting through the code before exporting a file:

                   

                   

                  //DESCRIPTION: Export alternative layouts as interactive PDF files

                  #target indesign

                   

                   

                  /*

                      Here is my solution (actually, not only mine - I found similar script and modified them to make it work the way you need).

                   

                  This script has been updated for Interactive PDF exporting but still shows a dropdown menu for print presets. Select any preset from the list and press okay to run the script. The PDF preset will be ignored in favour of an interactive PDF export with values selected in the code near the end. Choose JPG compression and PPI

                    

                      UPDATE:

                      There's a chance that any preset settings would not be applied, since    app.interactivePDFExportPreferences (Interacticve PDF) is completly different from the app.pdfExportPreferences (Print PDF)    API: http://www.indesignjs.de/extendscriptAPI/indesign-latest/#InteractivePDFExportPreference.h tml

                        

                      If you have suggestions of how to improve this code - feel free to contact me   

                      Oleh Melnyk  oleh.melnyk@gmail.com

                    

                      Change log:

                      [created]    5 November 2014

                      [modified]   3 August 2017      (export to interactive PDF instaed of print PDF)

                      [modified]  18 August 2017     (fix export to interactive PDF - set export page range to app.interactivePDFExportPreferences insteadd of app.pdfExportPreferences)

                  */

                   

                   

                  if(!app.activeDocument.saved){

                      var win = new Window('dialog', 'ERROR: Unsaved document');

                      win.orientation = 'column';

                    

                      with(win){

                          win.header = add('statictext', undefined, 'You need to save your document (give it a name) before exporting to PDF');      

                          win.button = add('button', undefined, 'OK');

                      };

                   

                   

                      win.show();

                      exit();

                  }

                   

                   

                  var pagesCount = app.activeDocument.pages.length;

                  var alternativeLayout = []; // arrays with alternative layouts names

                   

                   

                  var filePath = app.activeDocument.fullName.fsName;

                  var fileNameWithPath = filePath.replace(/.indd/, ""); // remove indesign .indd extenstion, as we don't need it

                   

                   

                  // dirty way to get all alterative layouts names - there should be a better way, but for now I don't know how

                  for(var i = 0; i < pagesCount; i++){  

                      if(alternativeLayout[alternativeLayout.length-1] != app.activeDocument.pages[i].appliedAlternateLayout.alternateLayout){

                          alternativeLayout.push(app.activeDocument.pages[i].appliedAlternateLayout.alternateLayout );

                          i += app.activeDocument.pages[i].appliedAlternateLayout.alternateLayoutLength-1; // speed up searching for the next alt layout

                      }

                  }

                   

                   

                  // CORE of the script from here: http://indisnip.wordpress.com/2010/08/02/simple-pdf-export-with-preset-selection/

                  var presets = app.pdfExportPresets.everyItem().name;

                  presets.unshift("- Select PDF Preset -");

                   

                  var win = new Window('dialog', 'PDF Export Presets');

                  win.orientation = 'row';

                   

                   

                  with(win){

                      win.header = add('statictext', undefined, 'Select PDF Export preset:');

                      win.PDFExport = add('dropdownlist',undefined,undefined,{items:presets});

                      win.PDFExport.selection = 0;

                      win.button = add('button', undefined, 'OK');

                  };

                   

                   

                  win.center();

                  window = win.show();

                   

                  if(window == true && win.PDFExport.selection.index != 0){

                      preset = app.pdfExportPresets.item(String(win.PDFExport.selection));

                   

                   

                      for(var alt = 0; alt < alternativeLayout.length; alt++){

                          app.interactivePDFExportPreferences.pageRange = alternativeLayout[alt];

                      

                          app.interactivePDFExportPreferences.pdfMagnification = PdfMagnificationOptions.FIT_PAGE; // General > Viewing > View

                          app.interactivePDFExportPreferences.pdfPageLayout = PageLayoutOptions.SINGLE_PAGE; // General > Viewing > Layout

                          app.interactivePDFExportPreferences.viewPDF = false; // General > Options > View after exporting

                          //app.interactivePDFExportPreferences.pdfRasterCompression = PDFRasterComprestionOptions.JPEG_COMPRESSION; // Compression > Image Compresion > Compresion

                          app.interactivePDFExportPreferences.pdfJPEGQuality = PDFJPEGQualityOptions.HIGH; // Compression > Image Compresion > JPEG Quality

                          app.interactivePDFExportPreferences.rasterResolution = 100; // Compression > Resolution (ppi)

                          app.activeDocument.exportFile(ExportFormat.INTERACTIVE_PDF, (new File(fileNameWithPath + "_" + alternativeLayout[alt] + ".pdf")), false, preset);

                      }

                  }else{

                      var win = new Window('dialog', 'ERROR: No PDF Preset selected');

                      win.orientation = 'column';

                   

                   

                      with(win){

                          win.header = add('statictext', undefined, 'You need to select PDF Preset before exporting to PDF');      

                          win.button = add('button', undefined, 'OK');

                      };

                   

                   

                      win.show();

                      exit();

                  }