How to get the number of pages in exported PDF? #3791

Closed
opened 2026-02-05 07:29:09 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @Bouni on GitHub (May 9, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

I already modified the PDF export with the help of a custom theme and the gist of @ssddanbrown as a starter.

He shows how to get the page number via CSS:

.print-page-number:after {
        content: "Page "counter(page);
}

This gives just Page 1 for example but I would like to have Page 1 of 3 for example.

Any hints how to get the total number or where to look for examples?

Exact BookStack Version

v23.02.3

Log Content

No response

PHP Version

No response

Hosting Environment

Docker container (lscr.io/linuxserver/bookstack)

Originally created by @Bouni on GitHub (May 9, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario I already modified the PDF export with the help of a custom theme and the [gist](https://gist.github.com/ssddanbrown/bcc9d2e73ec8144a7f4807fd10ddc863) of @ssddanbrown as a starter. He shows how to get the page number via CSS: ```css .print-page-number:after { content: "Page "counter(page); } ``` This gives just `Page 1` for example but I would like to have `Page 1 of 3` for example. Any hints how to get the total number or where to look for examples? ### Exact BookStack Version v23.02.3 ### Log Content _No response_ ### PHP Version _No response_ ### Hosting Environment Docker container (lscr.io/linuxserver/bookstack)
OVERLORD added the 🐕 Support label 2026-02-05 07:29:09 +03:00
Author
Owner

@ssddanbrown commented on GitHub (May 9, 2023):

From what I remember, there's no way to include the total as part of that, since it's being generated as the PDF rendering is going from start to finish, so there's no idea of total pages until the end. There might be some external ways to add such a number in, but nothing I know of that I can provide as a quick hack.

@ssddanbrown commented on GitHub (May 9, 2023): From what I remember, there's no way to include the total as part of that, since it's being generated as the PDF rendering is going from start to finish, so there's no idea of total pages until the end. There might be some external ways to add such a number in, but nothing I know of that I can provide as a quick hack.
Author
Owner

@Bouni commented on GitHub (May 10, 2023):

OK, thank you for the quick reply anyway 👍🏽

@Bouni commented on GitHub (May 10, 2023): OK, thank you for the quick reply anyway 👍🏽
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3791