/PDF-Bookmarker

A tool to add bookmarks and title/author to PDF

Primary LanguageJavaScript

PDF-Bookmarker

A tool to add bookmarks and title/author to PDF using hexapdf

Usage

ruby Bookmarker.rb "<filename (without extension)>"

This program requires a correspondent json file with the same name as the PDF. The json files must follow the format below:

{
	"Info": {
		"BookTitle": string,
		"BookAuthor": string
	},
	"Outline": array of outlines
}

where each element of Outline should contain

"Title": string,
"Target": integer,
"Style": 0 or 1 or 2 or "Italic" or "Bold",
"Opened": boolean,
"Color": string,
"Bookmark": array of outlines

Some elements can be ommitted, for example,

{
	"Info": {
		"BookTitle": "a",
		"BookAuthor": "a"
	},
	"Outline": [
		{
			"Target": 180,
			"Title": "a",
			"Style": 2
		},
		{
			"Target": 192,
			"Title": "a",
			"Bookmark": [
				{
					"Title": "a",
					"Target": 90
				},
				{
					"Title": "a",
					"Target": 29,
					"Style": 1,
					"Color": "red"
				}
			]
		}
	]
}

is valid.

Future development

  • More options e.g. input/output filename, whether to optimize -> done
  • Json file generator (perhaps from pdftk's dump data?) -> partly done (from csv)
  • Provide a conprehensive document