Spaces:
Sleeping
Sleeping
import markdown | |
from weasyprint import HTML, CSS | |
def markdown_to_pdf_weasyprint(md_content, output_pdf="travel_guide.pdf"): | |
html_content = markdown.markdown(md_content) | |
css = CSS(string=""" | |
@font-face { | |
font-family: 'Noto Color Emoji'; | |
src: local('Noto Color Emoji'), url(https://github.com/googlefonts/noto-emoji/blob/main/fonts/NotoColorEmoji.ttf?raw=true) format('truetype'); | |
} | |
body { | |
font-family: 'Noto Color Emoji', sans-serif; | |
font-size: 14px; | |
} | |
""") | |
HTML(string=html_content).write_pdf(output_pdf, stylesheets=[css]) | |
return output_pdf |