Skip to content

Instantly share code, notes, and snippets.

@venkata-qa
Last active April 9, 2025 13:45
Show Gist options
  • Save venkata-qa/db1d17cd76e73283176bf2d82fbf1383 to your computer and use it in GitHub Desktop.
Save venkata-qa/db1d17cd76e73283176bf2d82fbf1383 to your computer and use it in GitHub Desktop.
import markdown
import pdfkit
# Read markdown content
with open('file.md', 'r') as f:
text = f.read()
# Convert to HTML
html = markdown.markdown(text)
# Convert HTML to PDF
pdfkit.from_string(html, 'output.pdf')
import markdown
from weasyprint import HTML
# Load your markdown file
with open('file.md', 'r') as f:
md_content = f.read()
# Convert markdown to HTML
html_content = markdown.markdown(md_content)
# Generate PDF
HTML(string=html_content).write_pdf("output.pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment