PDF Place and Export

JavaScript for Adobe InDesign
Latest update 11/16/2017

The script automates the task of placing PDF pages into an InDesign document, arranging the pages for a desired result, and exporting a new PDF. The script began as a means to create PDF proofs in spreads from print-ready pages, ensuring the proofs are children of the files that will go to press. Other scripts begin to serve this need, but fall short in many ways. Plus having so many PDFs to process, I needed greater automation. So I wrote this script with the intial goal of creating PDF proofs, and from there, more features were added. One notable feature is the ability to “unspread” printer spreads or reader spreads, converting either back to single pages.

  • Process a single PDF or entire folder of PDFs
  • InDesign document created from PDF page size
  • Include bleed and resolve overlapping bleeds in spine
  • Convert PDF in reader spreads to pages
  • Convert PDF in printer spreads to pages
  • Create printer spreads from PDF pages
  • Add spine effect when facing pages
  • Save resulting InDesign document
  • Export new PDF using PDF preset
  • Save and restore all settings

Free to download and use. Contributions of any amount are appreciated but not required.

PDF Place and Export screen
PDF Place and Export

Instructions for use

The interface has four sections: Process, Layout, Output, and Settings. When the OK button is clicked, processing begins.

Section 1: Process

File or Folder — selects a single PDF or an entire folder of PDFs to process. The path and name of the selected file/folder will appear to the right of the button. Selecting a file will clear any selected folder, and vice-versa. When processing a folder, only files with the .pdf extension are processed.

Normally each PDF is processed individually and results in a matching output PDF. To instead create a single PDF from a folder of many PDFs, enable the checkbox Combine folder contents into a single document. The output PDF will be named to match the selected folder plus the defined suffix (described below). Also note when this option is enabled, the output folder will default to the folder containing the selected input folder, not the selected input folder itself. Override as desired.

Section 2: Layout

These choices determine how placed PDF pages will be arranged in the InDesign document. Note that an existing document is not needed beforehand. The script will read the trim box of the PDF and create a new document of the same page size. If the PDF lacks a trim box, the user is notified and the script will attempt to read the crop box or media box instead, if the user chooses to continue.

Include bleed — the script uses the bleed box instead of the trim box when placing the PDF pages. If a PDF page lacks a bleed box, the script presents a warning and processing of that file will halt. If processing a folder, the user may choose to continue with the next file. For each file processed, once pages are placed, if Facing pages is enabled, the overlapping bleeds in the spine are resolved.

Facing pages — creates a document with facing pages enabled.

Add spine effect — creates a layer and master page labeled Spine effect with two gradient-filled rectangles that give the semblance of a shadow as the pages roll into the spine. Available only when facing pages is enabled.

Pages from spreads — places the PDF pages in the document and then rearranges the pages to “unspread” the pages back to their natural order.

Reader spreads — assumes the first page of the input PDF is a single page (cover) that determines the page size of the document, and of course, that pages to follow are spreads in ascending order. A final single page (back cover) is typical but not required. The script will process the PDF correctly in either case.

Printer spreads — assumes the first page of the input PDF is a spread of the last and first pages (back and front cover), and of course, that pages to follow are arranged as printer spreads, increasing low folio pages paired with decreasing high folio pages until reaching the center at the PDF’s last page. The page size of the document is set to half the width of the spread discovered at page one of the input PDF.

Important: If PDFs to process do not conform to the above assumptions, the final result will not be as desired. Ensure that all input PDFs match the assumption for the choice selected, including a bleed box defined when Include bleed is enabled, another assumption of the script. Use other PDF tools to prepare PDFs for processing as needed to satisfy these assumptions.

Create printer spreads — arranges the pages in the order required for a saddle-stitch booklet constructed of 4-page signatures, commonly referred to as printer spreads. This requires the page count be divisible by 4. If not, the user is prompted with an option to add blank pages to the end of the document. When processing is complete, the script produces half the number of single pages that are double the width of the actual page size, with two PDF pages placed side-by-side as a spread across each document page. This choice may be combined with Pages from reader spreads to “unspread” the PDF and create printer spreads instead. Obviously, for a PDF already printer spreads, it would be an exercise in futility, though the script won’t complain. The typical use of this choice is to process a single-page PDF in natural order, and from it, create printer spreads.

To create reader spreads, enable Facing pages and select a PDF Preset configured to export pages as spreads. As with printer spreads, this may be combined with other choices, for example, to “unspread” printer spreads and instead create reader spreads, and of course, to input a single-page PDF in natural order, and from it, create reader spreads.

Section 3: Output

For PDFs processed, whether a single file or entire folder, the resulting documents may be saved and/or immediately exported to new PDFs using a selected PDF Preset. Click the checkboxes to enable the desired choices.

Folder — the folder to which PDFs will be output. Whenever File or Folder is selected in the Process section, the choice here will change to the same folder as the input file or folder. Click the button and select another folder to override.

Save .indd — saves an InDesign document with the same name as the input PDF plus the suffix defined below (Original name +).

Export PDF — requires that a PDF Preset is selected from the drop-down list, which will be used to export the PDF. The PDF will be named the same as the input PDF plus the suffix below (Original name +).

Original name + — appends a suffix to the output files. This is optional if the output folder is not the input folder. When outputting to the input folder (the default), a suffix is required to prevent overwriting input files. If required and no suffix is defined, “_out” will be appended to the output file names.

Replace existing output files — when enabled, existing output files are replaced without user intervention. When disabled, the user is prompted to confirm the replacement of each existing output file.

Section 4: Settings

Current choices may be saved and restored later. Select from the Load drop-down list to choose saved settings, which will then update the current choices. Click the Delete button and the saved settings selected in the Load drop-down list will be permanently removed. Click the Save button, provide a name for the settings, and the current choices will be preserved. If the name already exists, the user may choose to replace the saved settings.

Each time processing occurs, the current settings are preserved, and the next time the script is launched, settings are restored to the last values used.

Note that the functionality to save settings requires a file to store the settings, which coexists in the script folder alongside the script file itself. It has the same name as the script but a different extension, “json”. The file may or may not be visible depending on the InDesign Scripts Panel option Display unsupported files. Normally only script files are visible, but when this option is enabled in the Script Panel fly-out menu, all files are visible.

PDF Place and Export


Version 17.11.16

a. Spine effect option performed only when facing pages enabled.
b. If facing pages disabled, remove excess master page.
c. Fix unhandled exception when include bleed but PDF has no bleed box.

For help installing scripts, see How to install and use scripts in Adobe Creative Cloud applications.

IMPORTANT: by downloading the script you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.