Export Each Alternate Layout to Separate PDF?

Explorer ,
Feb 21, 2017

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.9K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Export Each Alternate Layout to Separate PDF?

Explorer ,
Feb 21, 2017

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.9K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 21, 2017 0
New Here ,
Oct 30, 2017

Copy link to clipboard

Copied

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 !?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 30, 2017 0
Engaged ,
Oct 31, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 31, 2017 0
Adobe Community Professional ,
Oct 31, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 31, 2017 2
New Here ,
Oct 31, 2017

Copy link to clipboard

Copied

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.appliedAlternateLayout.alternateLayout)

    {

        alternativeLayout.push(app.activeDocument.pages.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;

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

    }

}

else

{

    alert("No PDF Preset selected");

}

Hope it helps, this works for me !

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 31, 2017 0
New Here ,
Nov 05, 2017

Copy link to clipboard

Copied

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.html

      

    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.appliedAlternateLayout.alternateLayout){

        alternativeLayout.push(app.activeDocument.pages.appliedAlternateLayout.alternateLayout);

        i += app.activeDocument.pages.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();

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 05, 2017 0
New Here ,
Jan 05, 2021

Copy link to clipboard

Copied

I'm getting this error:

 

Schermafbeelding 2021-01-05 om 14.55.44.png

 

What am i doing wrong?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 05, 2021 0
Contributor ,
Jan 06, 2021

Copy link to clipboard

Copied

Hi @ronaldv46449794,
I'm surprised this script ever worked for the people who posted it.
I corrected the version of anthonyoe, which exports an interactive PDF!
Not something I would recommend for PDFs used for printing.

//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.html

    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)
    [modified]    6 January 2021      (changed for-loop of fetching alternative layouts to an one-liner
*/


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

var alternativeLayout = app.activeDocument.sections.everyItem().alternateLayout;


// 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();

    var 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();
}


For the record – I changed the first for-loop fetching the alternate layouts. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 06, 2021 0
New Here ,
Jan 07, 2021

Copy link to clipboard

Copied

Thanks a lot! I tweaked te script a little bit to get high-res images for print. This works for me!

 

//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.html

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)
[modified] 6 January 2021 (changed for-loop of fetching alternative layouts to an one-liner
*/


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

var alternativeLayout = app.activeDocument.sections.everyItem().alternateLayout;


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();

var 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 = true; // General > Options > View after exporting
//app.interactivePDFExportPreferences.pdfRasterCompression = PDFRasterComprestionOptions.JPEG_COMPRESSION; // Compression > Image Compresion > Compresion
app.interactivePDFExportPreferences.pdfJPEGQuality = PDFJPEGQualityOptions.MAXIMUM; // Compression > Image Compresion > JPEG Quality
app.interactivePDFExportPreferences.rasterResolution = 300; // 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();
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 07, 2021 0
Contributor ,
Jan 07, 2021

Copy link to clipboard

Copied

Hi @JK-82,

if you want a PDF for print, I highly recommend changing
ExportFormat.INTERACTIVE_PDF to ExportFormat.PDF_TYPE
and 
app.interactivePDFExportPreferences.pageRange to app.pdfExportPreferences.pageRange

All other app.interactivePDFExport... stuff can be removed then.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 07, 2021 0