How can I edit the Table of Contents of a PDF file on Linux? I tried
pdfedit but I can't find where the content table list is stored.
A very nice alternative is to use HandyOutliner, which works for PDF and DJVU. It also provides very good functionality for editing the table of contents.
Additionally there is the very handy python script called document-contents-extractor to extract contents from PDF's or DJVU's. It can be installed with pip (for me on Fedora
pip3 install --user document-contents-extractor). It requires some additional dependencies to be installed as found in the instructions here.
You can use pdf.togen to edit the
pdftocioto get the
tocof the pdf
- edit the
- write back to the pdf with
Further more, if the pdf has no
toc, you can also use
pdf.tocgen construct the
toc with multiple ways:
- Manually edit a
tocfile and write to the pdf (this is useful when there is no way automatically detect the toc, for example: a pdf file each page is scanned image).
- Use tools in
pdf.tocgento construct the toc automatically based on the different styles each level of
tocuses. A small script can be used to automate this process once you understand how
SIMPLE to edit.
To edit the page number if the table of contents is leading to the wrong page: Open the edit tool in the pdf. Right click on the line you wish to edit. A menu will open ... if you have a link there, it will give you an edit link option ... click on it and the link properties opens. Select the actions tab where you can edit the page number. Keep in mind the labels on the pages may not be the same number if you started page 1 on other than the cover page.
If you only have text and no page link: Open the edit tool in the pdf. Select "Link" > "Add/Edit Web or Document Link" in the menu. Use the crosshair to select the area of text where you want to put the link... a "Create Link" should show once you have drawn the box area. Choose the Link Action "Go to a page view and hit "Next". A box "Create Go to View" should pop up. Scroll to the page you wish the link to go tov and draw a box around the area (full page or section). Choose button to "Set Link". Close the edit tool and try the link.
I find if I set the bookmarks up myself using the formula with switches in Word rather than trusting the automatic bookmarking, I have better control of the results in the conversion. I also make sure I export the Word using the Export>Create PDF/XPS document to better replicate Word with less conversion issues.
HandyOutliner a great tool. I used it on Windows 11. Just remember to press "write outline" to save the work. The save function seems to be broken. But the "write outline" would work everytime. Your file should not be open in another program. To work on it at same time, make a copy of file and than open the copy, and write to original file.