Bookmarks not unique on PDF Export for Table of Contents links #6174

Open
opened 2026-07-28 13:22:54 +02:00 by johnnyuk · 1 comment

Describe the Bug

Table of Content hyperlinks do not correctly link to the right pages when generating a PDF export of a book that has common named headers within pages of the book.
It appears to link to the last element within the page structure that uses the same name of the bookmark.

When editing the page and viewing the HTML code, the bookmark ID appears to be just a truncated version of the header text, unique to the page if there were duplicated headers with same text. But it is not unique enough within the book for use with PDF outputs.

Example PDF generated to show the issue where each page has a common "Medium Header" element just as example.

Steps to Reproduce

  1. Create a new book with multiple pages.
  2. On each new page add some random content with two or three sections using the same text as a header (i.e. "Medium Header") and mark as a header format that is known to appear in the Table of Contents (ToC)
  3. Generate a PDF export of the book.
  4. ToC automatically created, but clicking on one of the "Description" links will not take you to the right page element that would be expected for the ToC link.

Expected Behaviour

  1. Create a new book with multiple pages.
  2. On each new page add some random content with two or three sections using the same text as a header (i.e. "Medium Header") and mark as a header format that is known to appear in the Table of Contents (ToC)
  3. Generate a PDF export of the book.
  4. ToC automatically created with each link correctly associated with the section within the given page expected for the link.

Screenshots or Additional Context

Example screenshots of two different pages using the same content. An example usecase would be a "template" page that has common sections for describing a procedure or tasks with sections steps involved.

Browser Details

No response

Exact BookStack Version

v26.05.2

### Describe the Bug Table of Content hyperlinks do not correctly link to the right pages when generating a PDF export of a book that has common named headers within pages of the book. It appears to link to the last element within the page structure that uses the same name of the bookmark. When editing the page and viewing the HTML code, the bookmark ID appears to be just a truncated version of the header text, unique to the page if there were duplicated headers with same text. But it is not unique enough within the book for use with PDF outputs. Example PDF generated to show the issue where each page has a common "Medium Header" element just as example. ### Steps to Reproduce 1. Create a new book with multiple pages. 2. On each new page add some random content with two or three sections using the same text as a header (i.e. "Medium Header") and mark as a header format that is known to appear in the Table of Contents (ToC) 3. Generate a PDF export of the book. 4. ToC automatically created, but clicking on one of the "Description" links will not take you to the right page element that would be expected for the ToC link. ### Expected Behaviour 1. Create a new book with multiple pages. 2. On each new page add some random content with two or three sections using the same text as a header (i.e. "Medium Header") and mark as a header format that is known to appear in the Table of Contents (ToC) 3. Generate a PDF export of the book. 4. ToC automatically created with each link correctly associated with the section within the given page expected for the link. ### Screenshots or Additional Context Example screenshots of two different pages using the same content. An example usecase would be a "template" page that has common sections for describing a procedure or tasks with sections steps involved. ### Browser Details _No response_ ### Exact BookStack Version v26.05.2
Owner

Hi @johnnyuk,
Just to confirm, are you using some kind of customization to generate a more extensive table of contents in book exports?
By default, I thought we only list the chapters/pages in the export TOC for book exports, hence why this has not been raised before.

I guess it would also still be an issue for manually created id-based hyperlinks in content too though.

Hi @johnnyuk, Just to confirm, are you using some kind of customization to generate a more extensive table of contents in book exports? By default, I thought we only list the chapters/pages in the export TOC for book exports, hence why this has not been raised before. I guess it would also still be an issue for manually created id-based hyperlinks in content too though.
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bookstack/bookstack#6174
No description provided.