A script that moves a table of contents from the end of a PDF file to just after the cover page. Useful when working with troff/groff.
Go to file
Blake Rain 99d46d023f
build / build (push) Successful in 37s Details
chore: add link to releases page
2024-07-04 18:56:11 +01:00
.gitea/workflows fix: try running `update` first 2024-07-04 18:50:14 +01:00
.gitignore chore: add sources 2024-07-04 18:26:47 +01:00
LICENSE Initial commit 2024-07-04 19:26:18 +02:00
Makefile chore: add sources 2024-07-04 18:26:47 +01:00
README.md chore: add link to releases page 2024-07-04 18:56:11 +01:00
demo.ms chore: add sources 2024-07-04 18:26:47 +01:00
toc-data.awk chore: add sources 2024-07-04 18:26:47 +01:00
toc-rel.sh fix: don't need `pdfinfo` anymore 2024-07-04 18:54:27 +01:00

README.md

toc-rel

A script that moves a table of contents from the end of a PDF file to just after the cover page. This is useful when you're using troff/groff and cannot have your macro package move the TOC.

See the following blog post to learn about these scripts in more detail:

https://blakerain.com/blog/moving-toc-in-groff-pdfs/

The script that performs the TOC movement is toc-rel.sh, and it has an accompanying AWK script in toc-data.awk which is used to rewrite the bookmarks data in the PDF.

You will need to have the following additional tools to hand:

  • pdfgrep, which is used to search for text in a PDF, and
  • pdftk which performs the actual PDF modification.

A demonstration file using the ms macro package is included, which can be built using the included Makefile. Running make will use groff to create the PDF, and then use toc-rel.sh to move the table of contents to just after the cover page, updating any bookmarks as required.

You can find the example PDF for download on the releases page.