Markdown to PDF Converter
This project provides a CLI and a web-based API service for converting Markdown files into PDF and optionally HTML files.
Features
- Convert Markdown files to PDF with syntax highlighting.
- Optionally generate an HTML version of the output.
- Custom CSS support for styling.
- Adjustable page size and margins.
- List available code highlighting styles.
- FastAPI-based web service with RESTful API.
Installation
To install the required dependencies, use:
pip install -r requirements.txt
CLI Usage
python convert.py [INPUT_FILE] [OUTPUT_FILE] [OPTIONS]
Arguments:
INPUT_FILE(optional): Path to the Markdown file.OUTPUT_FILE(optional): Output PDF file path.
Options:
--style, -s(default:xcode): Code highlighting style.--css, -c: Path to a custom CSS file.--page-size(default:A4): Page size options (e.g.,Letter,A3).--margin(default:0.05in): Page margin settings.--html, -h: Also generate an HTML file.--list-styles, -l: List all available code highlighting styles.
Example:
python convert.py sample.md sample.pdf --html --style=monokai
API Usage
You can run the FastAPI web service to provide Markdown-to-PDF conversion:
python serve.py --host 127.0.0.1 --port 8882
API Endpoints
Convert Markdown to PDF
POST /api/topdf
Parameters:
mdcontent: Markdown content as a form parameter.
Response:
- Returns the generated PDF file.
Health Check
GET /health
Response:
{"status": "ok"}
Running the Server
To start the web server:
python serve.py
By default, the server runs on http://127.0.0.1:8882/.
Dependencies
Clickfor the CLI interface.FastAPIandUvicornfor the web service.MarkdownConverterfor conversion logic.
License
This project is licensed under the MIT License.
Metadata
Release files for xpdf 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xpdf-0.0.2.tar.gz | 786.6 kB | With provenance | Details for xpdf-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xpdf-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for xpdf-0.0.2-py3-none-any.whl |
Total release size: 1.6 MB
Release files / xpdf-0.0.2.tar.gz
| Download URL | xpdf-0.0.2.tar.gz |
|---|---|
| Size | 786.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9ed4ff2108dff4333f03541a271f365f18e9f079eaa6668a728549899a2ddb2
|
|
BLAKE2b-256 checksum How to use checksums |
26a497eb9398463dbdbeb5617e018e9d5490ed40a8e030f6b5d94fd58e519288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 3, 2025.
Transparency logRelease files / xpdf-0.0.2-py3-none-any.whl
| Download URL | xpdf-0.0.2-py3-none-any.whl |
|---|---|
| Size | 785.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4211068bb25f1e5649ae4e181813a90f53ca8c635aa1d0fc26cf2b8b7ea60800
|
|
BLAKE2b-256 checksum How to use checksums |
1fe0134fbea10fa10db48b6212101ab3cd209c67a3643547abdf26aa584ffe50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 3, 2025.
Transparency logSecurity for xpdf 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xpdf-0.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 3, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.