PDF Export Single Pages

JavaScript for Adobe InDesign
Latest update 10/18/2017

The script exports an InDesign document to single-page PDFs using a selected PDF Preset.

  • Export an entire document as single-page PDFs
  • Page labels at the beginning or end of output file names
  • Absolute (document) numbering or by section
  • Set minimum digits to pad section and page labels
  • Preview example file name before proceeding
  • Export all pages, a single page, or any range or ranges of pages
  • Export using any defined PDF Preset
  • Exports PDFs in the background
  • Save and restore all settings

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

PDF Export Single Pages screen 1
Download
PDF Export Single Pages

Instructions for use

The interface has four sections: File naming, Preview, Output, and Settings. When the OK button is clicked, exporting begins. As when exporting a PDF normally, exporting occurs in the background. Progress may be tracked in the InDesign Background Tasks palette (Window -> Utilities -> Background Tasks).

Section 1: File naming

Base name — defaults to the active inDesign document name minus its file extension (.indd) and may be revised to any desired text provided it is a valid file name. Do not include any extension. “.pdf” will be added to the base name and unique label for each page exported. For saved settings or last used settings that preserve base name, this value will not be default. Use the Reset button to restore the default.

Reset — reverts base name to default (document name minus extension). Useful when last used settings include base name and the current value is undesired.

Page label at — the choice to begin the file name with the label, or end the file name with the label.

Separator — any character or characters to insert between the base name, the section label, and the page label. Default is a single underscore.

Numbering — choice to export PDF pages numbered by the document sequence (absolute numbering), or export PDF pages by sections and page numbers as they appear in the layout.

Document — ignores sections and how page numbers appear in the layout. The first page of the document is always labeled 1, the second page is always labeled 2, etc., until reaching the last physical page of the document.

Sections — takes into account any sections and the page numbers as they appear in the layout. For example, a document with multiple sections will have either a different starting page number for each section, or a different numbering style for each section. In the case of front matter, a typical scenario is the initial section begins at page one but is represented by the Roman numeral one, “i”, and the next page is “ii”, etc. Then a section follows that again begins at page one, but instead uses Arabic numerals (1,2,3, etc.). In this case, the first page of front matter will be labeled “basename_01_001.pdf” (section 1, page 1). For an example having 12 pages of front matter, the last page of the section will appear in the layout as page “xii” and will export as “basename_01_012.pdf” (section 1, page 12). Once past the front matter, then comes a new page 1 (the real page 1, as it appears in the layout). This will be labeled “basename_02_001.pdf” (section 2, page 1). And so on.

Whether numbering by document or by section, the goal is to produce single-page PDFs that will sort naturally in the intended order. This facilitates flowing pages into a prepress workflow and avoids pagination errors that may occur if having to manually position pages in the run list due to file naming that does not conform to a logical sequence. Section numbering is especially helpful when re-importing selected pages after a post-proof correction round. The benefit is that files are named the same as the page number that appears in the layout, which reduces confusion and the potential for error.

Minimum digits — controls how section and page labels are prefixed with zeros to become a minimum number of digits. This prevents the erroneous file sorting behavior still present in some systems, in which 10 precedes 2 because 1 precedes 2, even though 10 is greater in value. By adding a prefix of zeros (also known as “padding”), the same example instead becomes 010 and 002, which sort correctly under all circumstances, as 002 precedes 010.

Minimum digits for sections and pages may be adjusted to any value provided both are no less than the document requires. For example, if a document is composed of 192 pages, it is not possible to set the minimum digits for pages to less than 3, for obvious reasons. The same applies to section labels.

Include section label — when the document contains multiple sections or alternate layouts, and those sections or layouts share duplicate page numbers, a section label is required. Otherwise output of pages of the same number would overwrite each other. In this case, Include section label is forced on (checked but disabled so that it may not be unchecked). The choice to disable is available only when the document contains a single section and no alternate layouts, or all page numbers are unique.

The option to exclude a section label is useful in cases where a project is broken into separate documents, each consisting of a single section, but each of the documents is a unique range of page numbers. Once all combined, the project becomes a continuous page range, making section labels unnecessary. In such a scenario, there is no harm in having a section label, but it is excess and may not be desired. When this option is disabled, documents of a single section that begin at a higher page number may be exported with section numbering, producing files labeled as the page numbers appear in the layout, but without the excess “01” section label. For example, if the document is one section and set to begin at page 25, and Include section label is unchecked, the first page of the document exports as “basename_025.pdf” rather than “basename_01_025.pdf”.

IMPORTANT: the script has no means to know if multiple documents from a single project have overlapping page ranges. Ignoring this could lead to overwriting pages that mistakenly share the same number, regardless of including a section label or not (all will default to section 01 anyway, unless manually configured otherwise). For such a project, first ensure each document uses a unique page range that makes sense once combined — no pages with the same number, and no gaps of page numbers between documents that are considered sections though each contains only one section.

Number sections starting at — the number applied to the document’s initial section, which is then incremented each section that follows. Useful when a collection of documents span several sections, and the exported pages of subsequent sections require a section label greater than the preceding section. In this scenario, it is the user’s responsibility to set this value accordingly.

Section 2: Preview

There is no user interaction here, only a means to see an example output file name based on the current choices. As options change, the preview will refresh to show a new example. Note the example represents the first page of the active document, and if applicable, the first section of the document, or the value of Number sections starting at. The value set for pages to output, whether all or a range, has no effect on the preview.

Section 3: Output

Select folder — sets the output folder to which the PDF pages will be exported. Default is the folder in which the active InDesign document is located, unless saved settings that include a specific output folder have been selected.

Pages All/Range — exports all pages of the documents, a single page, or any range or ranges of pages. For a single page or range, the normal InDesign rules for identifying pages are recognized. Use section and/or alternate layout prefixes combined with the page number as it appears in the layout, or enter the plus sign (+) followed by the absolute page number. Separate the first and last pages of a range with a hypen (-) and separate multiple pages or page ranges with a comma (,).

PDF preset — select a PDF preset that will be used to export the pages.

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

All settings 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 and give the settings a name, and the current choices will be preserved. If the name already exists, the user may choose to replace the saved settings.

When settings are saved, there is also the choice to include Base name and/or Output folder.

PDF Export Single Pages screeen 2

If the saved settings are for a project that will always use a particular base name and/or always output to a particular folder, either or both of these choices may be enabled and the current values will be retained. For more generalized saved settings, when the only desire is to set the numbering choice, digits to pad labels, etc., either or both of these choice may be excluded. In this case, when the saved settings are loaded, the base name and/or output folder will remain the default value.

The script provides default saved settings named [Default] that will be created if the settings do not exist. The values do not include base name or output folder, so that selecting [Default] reverts these values. The [Default] saved settings cannot be deleted but may be updated to any desired values by saving settings named [Default], which then overwrites the default settings.

Each time exporting occurs, the current settings are preserved, and the next time the script is launched, settings are restored to the last values used. IMPORTANT NOTE: because of the script functionality to retain Base name and/or Output folder, these values from the last settings used may not be desired. To return base name to default, click the Reset button right of the base name input field, and for output folder, manually select the desired choice. You may also change both values by selecting other saved settings. As well, the built-in [Default] settings will revert to the default base name and output folder.

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.

Download
PDF Export Single Pages

CHANGE LOG

Version 17.10.18

a. Added reset button to restore default base name.
b. Create saved settings [Default] if it does not exist, and saved settings file if it does not exist.
c. Disable delete settings button if none are selected or [Default] is selected.
d. Allow disabling Use section label when all page numbers are unique, even when multiple sections/layouts exist.
e. Page label minimum digits limited to number of digits of highest page label rather than number of digits of total document pages.

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.