Vault To Pdf
This project provides a simple Python script that combines multiple Markdown files (nested in folders) into a single PDF document.
Markdown to PDF Converter
Table of Contents
About
This project provides a simple Python script, markdown-to-pdf.py, that combines multiple Markdown files into a single PDF document. This is used here to export an entire Obsidian vault to one, single .pdf file. The script uses Pandoc and a PDF engine (WeasyPrint by default) to generate the PDF.
I'm not proficient in Python, since Typescript is my main language, so I'm not sure if this is the best way to do this. I'm open to suggestions and improvements.
Getting Started
These instructions will help you get a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
Before running the script, you need to have Python installed on your system along with the following dependencies:
You can install them using your system's package manager or by following the instructions on their respective websites.
Installing
-
Clone the repository to your local machine.
-
Ensure you have the required dependencies installed by running:
pandoc --version weasyprint --versionIf the commands return version information, the dependencies are installed correctly.
-
Install the required dependencies using
brew:brew install pandoc brew install weasyprint -
Navigate to the project directory and run the script with Python:
python markdown-to-pdf.py
Usage
To use the script, simply run it from the command line. The script is configured to search for Markdown files in the vault_path directory, combine them into a single Markdown file (md_output_path), and then convert this combined Markdown file into a PDF (pdf_output_path) using Pandoc and WeasyPrint.
You can modify the vault_path, md_output_path, pdf_output_path, pdf_engine, and pdf_title variables in the script to customize the input directory, intermediate Markdown file path, output PDF path, PDF engine, and PDF title, respectively.
I personally use this script to export my entire Obsidian vault to a single PDF file. I then use this PDF as a source file for chatGPT to help answer questions about my notes. The script is designed to work with Obsidian vaults, but you it can to work with any directory containing Markdown files.
How to Install
- Download the ZIP or clone the repository
- Open the folder as a vault in Obsidian (File → Open Vault)
- Obsidian will prompt you to install required plugins
Stats
Stars
1
Forks
0
Last updated 20mo ago
Tags