You are not logged in.
I recently printed The Rust Programming Language Book (https://doc.rust-lang.org/stable/book/ - see the top-right icon for printing). I then found out it has no index/ToC. What's worse is that the chapters are not even enumerated, so good luck finding anything...
I was wondering, then, if there was any tool to generate a table of contents of a PDF. The file has correctly marked sections and subsections, and it has, fortunately, page numbers. So far, I've found close to nothing online: Windows proprietary programs, paid web services, etc. I was wondering if this is something doable with one of those fancy little CLI utilities that I haven't discovered yet. Or, maybe, there is a relatively easy way to create a script that gets the job done.
I am asking for any help or guidance in this nice community :-)
Last edited by icar (2022-01-25 20:26:20)
Online
Tried libreoffice?
Offline
Tried libreoffice?
I did, yes. After 5min loading, it presented an editable document with parts of the text wrongly formatted.
Example: https://i.imgur.com/z6Cd8Po.png
Online
In the case of the rust book you can use pdf.tocgen (Example:
python -m pdfxmeta -p 8 -a 1 ../The\ Rust\ Programming\ Language.pdf "Getting Started" > data.toml
python -m pdfxmeta -p 3 -a 2 ../The\ Rust\ Programming\ Language.pdf "Who Rust Is For" >> data.toml
python -m pdfxmeta -p 4 -a 3 ../The\ Rust\ Programming\ Language.pdf "Students" >> data.toml
python -m pdftocgen ../The\ Rust\ Programming\ Language.pdf <data.toml >data.toc
python -m pdftocio ../The\ Rust\ Programming\ Language.pdf <data.toc
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
Thanks progandy, that is exactly what I was looking for.
Online