This project allows you to convert Markdown (.md) files into a single PDF document with support for styles and formatting. The program uses pdfkit (which wraps wkhtmltopdf) for generating PDF and markdown2 for converting Markdown to HTML. It is suitable for GitBook repositories.
- Conversion of all Markdown files in the directory into a single PDF document.
- Automatic removal of metadata, if present, from each Markdown file created in GitBook.
- Syntax highlighting for code.
- HTML processing (optional) for better formatting.
- Make sure you have Python version 3.x installed.
- Make sure you have
wkhtmltopdfinstalled. - Install the Python dependencies:
pip install markdown2 pdfkit
Configure the variables at the beginning of the script:
repo_path: the path to the directory with Markdown files.output_pdf_path: the path to save the output PDF file.excluded_files: Markdown files that should not be included in the PDF.debug_html: ifTrue, a debug HTML file will be created.include_page_break: ifTrue, adds a page break between files.enable_html_processing: ifFalse, disables additional HTML processing.
- Ensure all dependencies are installed, including
markdown2andpdfkit. - Configure the variables at the beginning of the script (see the Configuration section).
- Optionally, configure the
style.cssfile for styling your PDF. - Run the script with the command:
python main.py
- After the script runs, the output PDF file will be saved at the path specified in
output_pdf_path.
Optionally: If debug_html is set to True, a debug HTML file named debug.html will be generated.