Repository navigation
Modify How TOC Reports Bookmarked Page Numbers? #893
|
Hello all, first post so please be gentle. I've looked!!! Say I insert a bookmark at page 1 and page 59 of a document. If I then generate a table of contents, the TOC counts as a page, so that the hover information on the bookmarked entry reads "Go to page 2" or "Go to page 60". Those are literally the correct page numbers inside the document, but I can't find a way to bump the bookmark up to using page 2, without it actually using page 2 (which becomes page 3 when the TOC is inserted). Am I missing a way to modify the bookmarks so that the insertion of a new page (the TOC) is accounted for? Thanks for any help, |
Replies: 2 comments
|
You're not missing an option in the TOC tool. Bookmarks and TOC links point at physical pages, and after the TOC is prepended your "page 1" really is the 2nd page of the file, so the link has to target page 2. What you want is for the viewer to call that page 1, and that's what PDF page labels are for. BentoPDF has an Add Page Labels tool for exactly this. Run it on the PDF after generating the TOC, with two rules:
Keep "Remove existing page labels" checked (it is by default). If your TOC spans more than one page, use I tested this on a 60 page file with bookmarks on 1 and 59: after the TOC the links still go to physical pages 2 and 60, but the page labels read i, 1, 2 ... 59, so viewers that honour labels (Acrobat, Firefox) show "1" and "59" in the page number box. The printed numbers in the generated TOC already say 1 and 59. The TOC step itself writes an empty label for every page, which is probably why your viewer falls back to raw numbers. One caveat: whether a link's hover tooltip uses labels or raw page numbers depends on the viewer, so a few may still say "page 2" there. Tool source: https://github.com/alam00000/bentopdf/blob/main/src/js/logic/add-page-labels-page.ts |
|
Ah. What you were saying sank in, thanks for the reply. (I was thinking the TOC itself would change). I'm running Linux using qpdfview, which appears not to honor the tooltip, but that's okay, the bulk of my users will indeed either use an Acrobat reader or Firefox, and that works fine. Again, thanks for the help. I'm self-hosting BentoPDF on a Pi Zero W that's also running a backup Pi-Hole and Apache serving a couple other small sites ... Jim |
You're not missing an option in the TOC tool. Bookmarks and TOC links point at physical pages, and after the TOC is prepended your "page 1" really is the 2nd page of the file, so the link has to target page 2. What you want is for the viewer to call that page 1, and that's what PDF page labels are for.
BentoPDF has an Add Page Labels tool for exactly this. Run it on the PDF after generating the TOC, with two rules:
1, style Lowercase Roman (the TOC page becomes "i")2-end, style Decimal Arabic, start value 1 (a bare2-is rejected as a bad page spec,2-endor2-61work)Keep "Remove existing page labels" checked (it is by default). If your TOC spans more than one p…