The PDF merger supports automatic generation and insertion of a Table of Contents (TOC) based on configuration and input files. The TOC functionality is conditional and depends on the presence of a designated "First Page" file in the burst distribution settings.
If no such file is provided, TOC-related processing is entirely skipped.
For details about PPT generation, refer to How PPT Generation Works.
Input File Mapping
During the merge process, the system receives a set of input files with predefined aliases. These are mapped internally as follows:
| Alias | Configuration Mapping | Purpose |
|---|---|---|
first_page | config.toc_file | Serves as the TOC template page |
last_page | config.def_file | Appended to the end of the final document |
logo | config.logo_file | Applied to each page as a visual Element |
This mapping is handled during the configuration update phase of the merger.
TOC Activation Logic
The TOC is generated only when a TOC template file is provided:
- If config.toc_file is not set, all TOC-related logic is skipped.
- If config.toc_file is set, the merger performs TOC generation and enhancement steps.
TOC Insertion Workflow
When a TOC template is available, the merger executes the following sequence:
- Insertion of TOC Template
- The uploaded "First Page" PDF is inserted as the first page of the merged document.
- No additional pages are created for the TOC.
- TOC Population
- The inserted first page is treated as a visual template.
- Interactive Elements (clickable links) are overlaid onto this page.
- Content Page Enhancements
- Each subsequent page in the document is augmented with:
- Page numbers
- Navigation links back to the TOC
- Each subsequent page in the document is augmented with:
TOC Template Behavior
The uploaded "First Page" file functions as:
- A static visual layout designed by the user
- A background layer onto which interactive elements are applied
The system does not modify the layout itself. Instead, it overlays link regions corresponding to document sections.
TOC Population Mechanism
TOC population is handled by a dedicated strategy component that inserts interactive links into the TOC page. These links correspond to sections within the merged document and enable direct navigation.
The link insertion process operates on the first page of the final PDF and applies clickable regions aligned with the TOC layout.
TOC Population Engines
The behavior of TOC population is controlled via the [TOC] section in the configuration file. Three engines are supported:
1. Default Engine
- Uses predefined link coordinates from an external configuration file.
- Requires explicit mapping of link positions to document sections.
2. Total-Dynamic Engine
- Detects text elements on the TOC page.
- Matches detected text to report titles dynamically.
- Eliminates the need for predefined coordinates.
3. Partially-Dynamic Engine
- Combines predefined structure with dynamic matching.
- Supports hierarchical relationships such as sections and subsections.
Default Configuration Behavior
By default:
- The TOC population engine is set to default.
- No TOC file is specified.
- As a result, TOC generation is disabled unless a "First Page" file is explicitly provided.
Responsibilities
User Responsibility
- Design and upload the TOC template (First Page file).
- Ensure that the layout aligns with expected section structure.
System Responsibility
- Insert the TOC template as the first page.
- Overlay interactive navigation links.
- Enhance content pages with navigation and pagination elements.
Summary
The PDF merger implements TOC functionality through a template-driven approach:
- A user-provided PDF defines the visual structure.
- The system enriches this structure with interactive navigation.
- The process is fully conditional and activated only when a TOC template is present.
This design ensures flexibility in presentation while maintaining consistent navigation behavior across merged documents.