How to add bookmarks to pdf files under linux

How to add bookmarks to pdf files under linux

For pdf files without bookmarks, how to add tags to the pdf? To facilitate reading. I used to use the pdf tool under windows, what is
it called? Intuitively, there are small directories nested under the large directory..., and then imported into the file

Is there such a tool under linux? Yes, it is pdftk.
Its label file is different from that of windows. It uses numbers to directly give the level of the directory (BookmarkLevel).
And each label uses 4 lines to describe its attributes. Take a look The following example
----------------------------------------
1. pdftk tag
format- ------------------------------------------
$ cat data.txt
BookmarkBegin
BookmarkTitle:Chapter 1 : List Processing
BookmarkLevel:1
BookmarkPageNumber:13
BookmarkBegin
BookmarkTitle:Chapter 2: Evaluation Practice
BookmarkLevel:1
BookmarkPageNumber:28
BookmarkBegin
BookmarkTitle:Chapter 3: How to write a function
BookmarkLevel:1
BookmarkPageNumber:33

Each bookmark is represented by 4 lines of content.

BookmarkBegin
BookmarkTitle: -- Your Title 1 --
BookmarkLevel: 1
BookmarkPageNumber: 10

BookmarkTitle, BookmarkLevel, BookmarkPageNumber (label name, level, page number) meaning is still very clear,


Let’s talk about how to export, import bookmark files, and edit bookmarks under Linux. That’s a manual job.
1. Install pdftk
apt install pdftk


----------------------------------------
2. Use pdftk to export the original bookmark
-- --------------------------------------
Although the content may be empty, we need this format file
pdftk my.pdf dump_data output data.txt

Note:
pdftk usage can be man pdftk
where my.pdf is your pdf file
dump_data, update_info, cat, etc. are all operation commands
dump_data to indicate that the bookmark file
output is a keyword followed by the output file name.
The meaning of this keyword is to point out The output file name is data.txt


----------------------------------------
3. Edit bookmark file
----- -----------------------------------
Edit the exported data file data.txt.

To strengthen your understanding, you can first export a tagged pdf to try, and you will understand its meaning better.
Then you can compile a file in the format of data.txt above. As
for the tag name and page number information, it may take Extracted from the directory page in the file.
Then edit it into the required format

Adding tags is the main manual workload.
It is also the time to examine how the editor completes specific editing tasks. However, the basic information must be typed by hand, and then...


----------------------------------------
4. Import new bookmarks with pdftk
--- -------------------------------------
pdftk my.pdf update_info data.txt output new.pdf

Description:
update_info: The command indicates to update the label file, data.txt is the label file to be imported
output: indicates the file to be generated, new.pdf is the newly generated file name
Result: The bookmark data.txt is imported and new.pdf is generated


Use pdftk to extract the specified page
. Enter the extraction directory list to identify the directory and page number information
pdftk my.pdf cat 10-12 output 1.pdf
Description:
cat 10-12, cat indicates the extraction command, and 10-12 indicates the extraction page.
output 1.pdf, the output file name is 1.pdf

Guess you like

Origin blog.csdn.net/hejinjing_tom_com/article/details/129108403