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.

Revisions

  1. venkata-qa revised this gist Apr 9, 2025. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions convert_md_pdf.py
    Original file line number Diff line number Diff line change
    @@ -10,3 +10,21 @@

    # 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")

  2. venkata-qa created this gist Apr 9, 2025.
    12 changes: 12 additions & 0 deletions convert_md_pdf.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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')