Last active
April 9, 2025 13:45
-
-
Save venkata-qa/db1d17cd76e73283176bf2d82fbf1383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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