No description
Find a file
2024-06-07 10:02:57 +00:00
constants.py First commit 2024-06-07 10:02:57 +00:00
demo.py First commit 2024-06-07 10:02:57 +00:00
functions.py First commit 2024-06-07 10:02:57 +00:00
README.md First commit 2024-06-07 10:02:57 +00:00
requirements.txt First commit 2024-06-07 10:02:57 +00:00

README for Markdown to PDF Converter

Overview

This project provides a tool to convert Markdown content into a PDF file. It utilizes the wkhtmltopdf tool for rendering HTML into PDFs and a demo is provided: a simple Streamlit interface for user interaction. The main function allows to input Markdown text and customize the PDF output with options for font family, font size, and margins.

Installation

Prerequisites

  • Python 3.10 or higher
  • pip (Python package installer)

Dependencies

This project requires the following Python libraries:

  • pdfkit
  • markdown
  • streamlit (only for demo purposes)
  • wkhtmltopdf

Installing wkhtmltopdf on Linux

The wkhtmltopdf tool needs to be installed on your system. For Linux users, you can install it using your package manager. For example, on Ubuntu:

sudo apt-get install wkhtmltopdf

Setting up the Python Environment

  1. Clone the repository or download the source code.

  2. Navigate to the project directory.

  3. Create a virtual environment (recommended):

    python3 -m venv venv
    source venv/bin/activate
    
  4. Install the required Python packages:

    pip install -r requirements.txt
    

Configuration

Update the constants.py file to set the path to the wkhtmltopdf executable appropriate for your system. For Linux, it typically might be:

EXE_PATH = '/usr/bin/wkhtmltopdf'

Also, you can adjust the default font settings and margins in the constants.py file.

Usage

To run the demo-application:

  1. Activate your virtual environment if it's not already activated:

    source venv/bin/activate
    
  2. Start the Streamlit application:

    streamlit run demo.py
    
  3. Open your web browser and go to http://localhost:8501. You should see the Markdown to PDF Converter interface.

  4. Enter your Markdown content, customize the PDF settings if desired, and click the "Generate PDF" button. Once the PDF is generated, you can download it using the "Download PDF" button.

Features

  • Convert Markdown text to PDF.
  • Customize PDF appearance with options for font family, size, and margins.
  • Simple and interactive demo interface using Streamlit.