pip install md2pdf-python
md2pdf --help
md2pdf tests/demo.md -o tests/output-default.pdf
md2pdf tests/demo.md -o tests/output-default.pdf --html
md2pdf tests/demo.md -o tests/output-styles.pdf --css-file tests/demo.css --mermaid-config tests/demo.json
from md2pdf.core.converter import MD2PDF
md2pdf(input_file='input.md', output_file='output.pdf')
md2pdf(input_file='input.md', output_file='output.pdf', html=True)
md2pdf(input_file='input.md', output_file='output.pdf', css_file='custom.css')
md2pdf(input_file='input.md', output_file='output.pdf', css_file='custom.css', mermaid_config='custom-config.json')
body {
font-family: Arial, sans-serif;
font-size: 12pt;
}
h1 {
color: red;
}
h2 {
color: blue;
}
h3 {
color: green;
}
p {
color: black;
}
table {
border-collapse: collapse;
width: 100%;
}
{
"theme": "default",
"themeVariables": {
"fontFamily": "Times New Roman, serif"
},
"backgroundColor": "#F2F2F2"
}
mermaid render is based on Mermaid-CLI (mmdc), install it with:
npm install -g @mermaid-js/mermaid-cli