Skip to content

Generate bookmarks to each PDF starting point when merging multiple PDF files #867

Closed

Description

@gnapse

The "merge PDFs" route (POST http://localhost:3000/forms/pdfengines/merge) could include the feature of generating bookmarks in the PDF to each of the combined documents' starting points.

Each of the input PDFs potentially has a title as metadata. This title can be used to add a bookmark in the combined PDF, that points to the first page of that input document in the output document.

See #864

Example

Input: 4 documents titled "Intro" (2 pages), "Chapter 1" (10 pages), "Chapter 2" (12 pages), "Appendix" (3 pages)
Output: A single PDF as usual, but that also has bookmarks with each document's title, and pointing to the corresponding page:

  • "Intro" (points to page 1)
  • "Chapter 1" (points to page 3)
  • "Chapter 2" (points to page 13)
  • "Appendix" (points to page 25)

Why?

PDF reader apps often show this as a table of content in their own UI, for easier navigation:

CleanShot 2024-04-26 at 09 01 22@2x

Kindle and similar devices show this table of content as well.

Activity

  1. gulien commented on Aug 14, 2026

    @gulien
    Member

    Added in 65e5699, shipping in the next release.

    Merge now takes a titleBookmarks form field. Set it to true and Gotenberg adds one bookmark per input, labeled by its Title metadata (or the filename when the title is missing) and pointing to that document's first page. Each document's own bookmarks nest underneath, so you get a proper table of contents.

    Your exact example:

    curl \
    --request POST http://localhost:3000/forms/pdfengines/merge \
    --form files=@/path/to/intro.pdf \
    --form files=@/path/to/chapter1.pdf \
    --form files=@/path/to/chapter2.pdf \
    --form files=@/path/to/appendix.pdf \
    --form titleBookmarks=true \
    -o my.pdf

    Thanks for the clear write up, made this easy to build.

  2. gnapse commented on Aug 14, 2026

    @gnapse
    Author

    Thank you for adding this feature!

  3. added a commit that references this issue on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions