This repository provides tools to manage PDF metadata and bookmarks using either Node.js or Python.
- Overviews
- Features
- Prerequisites
- Configuration
- Bookmarks Format Guide
- Installation
- Dependencies
- License
- Contributing
This repository provides two implementations for managing PDF metadata and bookmarks:
- Node.js Implementation: Uses the Sejda API for processing.
- Python Implementation: Uses the PyPDF2 library for local processing.
- Edit PDF metadata (title, author, subject) with ease.
- Create and manage bookmarks for PDFs, including hierarchical structures.
- Node.js version leverages Sejda API for robust processing.
- Python version performs all operations locally.
- Node.js (v12 or higher)
- npm (v6 or higher)
- Python (v3.8 or higher)
- pip (v21 or higher)
Place these required files in the input folder:
-
PDF file: The PDF file for which you want to edit metadata and create bookmarks.
-
metadata.json: Contains metadata such as title, author, and subject for the PDF. The format is as follows:
{ "title": "Sample PDF", "author": "John Doe", "subject": "Sample Subject" }
-
bookmarks.json: Bookmark hierarchy with title, page numbers, and parent-child relationships. See the Bookmarks Format Guide for details.
-
index: The title and starting page of the section, separated by a /. For example:
-
This means the section Table of Contents starts on page 2.
"index": "Table of Contents/2"
-
-
children: Defines sub-sections or exercises under a parent bookmark.
-
This indicates a bookmark titled Exercise 1 starts on page 3.
"Exercise 1/3"
-
-
Hierarchy:
- Parent bookmarks contain a children array with their sub-bookmarks.
- Sub-bookmarks within a child (level 3 or deeper) are not currently added.
[
{
"index": "Table of Contents/2"
},
{
"index": "Complex Analysis/2",
"children": [
"Exercise 1/3",
"Exercise 2/6",
"Exercise 3/11",
"Exercise 4/17"
]
},
{
"index": "The Z-Transform/51",
"children": [
"Exercise 5/43",
"Exercise 6/52",
"Exercise 7/70",
"Exercise 8/85"
]
},
{
"index": "Partial Differential Equation/108",
"children": [
"Exercise 9/113",
"Exercise 10/119",
"Exercise 11/126",
"Exercise 12/136"
]
}
]
This is how the bookmarks will look in the PDF viewer:
-
Clone the repository:
git clone https://github.com/rohityadav-sas/PDF-Bookmarks-Creator.git
-
Navigate to the project directory:
cd PDF-Bookmarks-Creator
-
Choose the implementation you want to use:
-
Navigate to the nodejs directory:
cd nodejs
-
Install the required dependencies:
npm install
-
Prepare the configuration files as described in the Usage section.
-
Run the program:
npm start
-
Navigate to the python directory:
cd python
-
Install the required dependencies:
pip install -r requirements.txt
-
Prepare the configuration files as described in the Configuration section.
-
Run the program:
python main.py
-
axios: For making HTTP requests to the Sejda API.
-
axios-cookiejar-support: To handle cookies for the Sejda API.
-
tough-cookie: To handle cookies for the Sejda API.
-
pdf-lib: For editing PDF metadata.
- PyPDF2: For interacting with PDF files.
This project is licensed under the ISC License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.