PDF Place and Export

JavaScript for Adobe InDesign
Latest update 9/26/2018

The script places PDF pages into an InDesign document, arranges the pages for a specific result, and exports 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 go to press. From there more features were added. One notable feature is to “unspread” printer spreads or reader spreads, converting either back to single pages.

  • Process a single PDF or an entire folder of PDFs
  • Creates an InDesign document sized to match input PDF
  • Option to include bleed
  • If facing pages, resolves overlapping bleeds in the spine
  • Convert a PDF in reader spreads back to single pages
  • Convert a PDF in printer spreads back to single pages
  • Create printer spreads
  • Option to add spine effect
  • Export a new PDF using any PDF preset
  • Save and restore all settings
PDF Place and Export screen
Download
PDF Place and Export

You decide. Reward the author an
amount the solution is worth to you.

Instructions for use

The interface has four sections: Process, Layout, Output, and Settings. Enable desired options and click the OK button to begin. A progress bar is displayed while processing.

Section 1: Process

File or Folder — select a single PDF or a folder of PDFs to process. The path and name of the selected file or folder appears to the right of the button. Selecting a file clears any selected folder, and vice-versa. When processing a folder, only files with the .pdf extension are processed.

Combine folder contents into a single document — available when processing a folder. When enabled, rather than generating separate output files for each PDF the folder contains, the PDFs are combined into a single InDesign document and/or are exported to a single PDF. In this case, output files are named to match the selected folder plus the defined suffix (described below), and the output folder defaults to the parent of the selected input folder, rather than the input folder itself (to override, see Output section, Folder option). IMPORTANT NOTE: the InDesign page size is set to the trim size of the first page of the first PDF in the folder of PDFs to combine. Ensure all PDFs to combine share a common trim size.

Section 2: Layout

These choices determine how placed PDF pages are arranged in the InDesign document. An existing document is not required beforehand. The script reads the trim box of the PDF and creates a new document of the same page size. If the PDF lacks a trim box, the script presents a warning and attempts to read the crop box or media box instead, if the user chooses to continue.

Include bleed — when placing PDF pages, the bleed box is read, the document bleed is set to match, and pages placed include bleed. If a PDF page lacks a bleed box, the script presents a warning and processing of that file halts. If processing a folder, the user may choose to continue with the next file. For each file processed, if Facing pages is enabled, the overlapping bleeds in the spine are resolved.

Important: bleed is determined by comparing bleed box height against trim box height and calculating a value based on the difference. The script has no means to understand if a PDF page has unequal bleed margins, and so assumes all PDFs to process have equal bleed margins. Use other PDF tools to prepare PDFs for processing as needed to satisfy this assumption.

Limit bleed to — available when include bleed is enabled, this option allows the user to define a maximum bleed value. If the bleed value of placed PDF pages exceeds the defined value, they are cropped to limit bleed. As well, the document bleed is set no greater than this value.

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 that pages to follow are spreads in ascending order. The script tests this assumption by comparing the width of the first and second page of the input PDF. If the sizes match, there is not a single-page cover, and the script acts accordingly. A final single page (back cover) is typical but not required. The PDF is processed 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 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 expected. Ensure that 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 document is half the number of single pages that are double the width of the trim size, with two PDF pages placed side-by-side as a spread across each document page.

Section 3: Output

For PDFs processed, the resulting documents may be saved and/or immediately exported to new PDFs using any PDF Preset.

Folder — the folder to which InDesign documents are saved and PDFs are output. Whenever File or Folder is selected in the Process section, this value updates to the folder where the input file is located, or the folder selected to process. When the option Combine folder contents into a single document is enabled, this value updates to the parent of the folder selected to process. To override, click the button and select another folder.

Save .indd — saves an InDesign document named to match the input PDF plus the suffix defined below (Original name +).

Export PDF — requires that a PDF Preset is selected, which is used to export the PDF. The PDF is named to match the input PDF plus the suffix defined below (Original name +).

Original name + — a suffix of characters appended to output file names. The characters chosen must be legal to use in file names. By default, files are output to the same folder as the input files, making a suffix necessary, otherwise output files would overwrite input files. If the output folder differs from the input folder, a suffix is not required as there is no risk of overwriting files, but using a suffix is still encouraged to differentiate output files from their input. If required and no suffix is defined, the default suffix “_out” is appended to 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

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

The script provides default saved settings named [Default]. These settings cannot be deleted but may be updated to any desired values by saving settings and providing the name [Default], which then overwrites the default settings.

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

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.

Download
PDF Place and Export

CHANGE LOG

Version 18.9.26

  1. Miscellaneous syntax.

Version 18.9.23

  1. Fix flaw, delete setting confirmation removes setting from UI when responding 'no.'

Version 18.8.19

  1. Miscellaneous syntax.
  2. Revise settings object.
  3. Remove obsolete function settings restoreLast.
  4. Add function configureUi.
  5. Wrap work in process function, wrapped in try/catch.

Version 18.5.21

  1. No longer output failed document when other documents are open.
  2. Miscellaneous improved program logic.
  3. Revise PDF place pages program logic.
  4. Documents in spreads that contain a single page midway no longer halt placing pages.
  5. Properly handle reader spreads when page 1 is a spread rather than single page cover.
  6. Add option to limit bleed.
  7. Spine effect master pages set margins to zero.

Version 18.5.20

  1. Revise progress bar.
  2. Remove close button from progress bar.

Version 18.5.1

  1. Catch processing errors and alert user.
  2. Fix unhandled exception when combining PDFs and include bleeds, but a page lacks bleed.
  3. No longer close document on PDF box error.

Version 18.4.30

  1. Original Name +, replace illegal characters and alert user.
  2. Disable option Pages from spreads when processing folder.
  3. Read legacy settings removed.

Version 17.12.11

  1. Create saved settings [Default] if it does not exist.
  2. Create saved settings file if it does not exist.
  3. Disable delete settings button if none are selected or [Default] is selected.
  4. Add default PDF Preset, first discovered in list with PDF and X-4 in name.

Version 17.11.16

  1. Perform Spine effect option only when facing pages enabled.
  2. If facing pages disabled, remove excess master page.
  3. 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.