Linux printing software (CUPS) should allow to print into a PDF file as output. Applications that do not use CUPS, may still provide the printing to file option, which usually generates a postscript file. A postscript file can be converted to a PDF by using ghostscript (gs) on a commandline.
For indexes and TOC: as already mentioned - LaTex.
Arch Linux