Skip to main content
Participant
December 23, 2018
Answered

InDesign - Export Entire Book (.indb) to One PDF File Script

  • December 23, 2018
  • 1 reply
  • 2636 views

I got the following script (PrintChapter.jsx) set up to export a single book chapter (with assigned shortcut "Ctrl-P"). It works really fast.

var myPDFExportPreset = app.pdfExportPresets.item("[High Quality Print]");

// Change myPDFpreset to the name of the preset you want to use

var myDoc = app.activeDocument;

 

var myFolderName = myDoc.filePath;

 

// Apply a name to the PDF file based on the INDD file, but without the .indd extension

 

var myDocumentName =  myDoc.name.slice (0, -5);

 

var myFilePath = myFolderName + "/" + myDocumentName + ".pdf";

 

var myFile = new File(myFilePath);

 

// Do not open the PDF Export dialog box. Set "false" to "true" if you want the dialog box.

 

myDoc.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset);

What is the modification to print out an entire book (.indb) also in one shot without any dialog boxes, or opening all the chapter files?

This topic has been closed for replies.
Correct answer xxxxxxxxxxxxxxxxxxxxyyyy

Hi,

change line 5 of the code from

var myDoc = app.activeDocument;

to

var myDoc = app.activeBook;

But be sure that you have only the book file open in Indesign that you want to export.

I have no clue which book file Indesign considers as "active" when there are multiple book files open.

Greetings

1 reply

xxxxxxxxxxxxxxxxxxxxyyyy
Participating Frequently
December 23, 2018

Hi,

change line 5 of the code from

var myDoc = app.activeDocument;

to

var myDoc = app.activeBook;

But be sure that you have only the book file open in Indesign that you want to export.

I have no clue which book file Indesign considers as "active" when there are multiple book files open.

Greetings

Jongware
Community Expert
Community Expert
December 23, 2018

Nice minimal change

It works because the command to export an entire book is the same as that for an individual document: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Book.html#d1e59880__d1e60493

And I agree on the problems with 'activeBook' – after lots of problems with that, I made sure to add near the top of such scripts:

if (app.books.length != 1)

{

   alert ("Please make sure you only have exactly one book open. Thank you.");

   exit();

}

The funny thing is, 'activeBook' does work as expected when called from a Book's popup menu: https://indesignsecrets.com/add-missing-options-to-the-book-menu.php .)

Community Expert
December 24, 2018

Hi Jongware,

the right international keystring for the book panel menu is:

"$ID/BookPanelPopup"

Just tested that with my German InDesign CC 2019.

With that little correction in line 83 your BookOpenAll.jsx script will work with my German InDesign.

Regards,
Uwe