info:md2pdf

Ceci est une ancienne révision du document !


md2pdf

convertir un .md en .pdf

md2html (convertir un .md en .html)

# WeasyPrint
sudo apt update
sudo apt install python3-pip libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b
python3 -m venv weasyprint-env
source weasyprint-env/bin/activate
pip install weasyprint cairocffi
# check install
weasyprint --info

style-paysage.css

@page {
  size: landscape;
  margin: 1cm;
}

style-portrait.css

@page {
  size: portrait;
  margin: 1cm;
}

~/tpl/template-paysage.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <style>
    /* CETTE RÈGLE GARANTIT LE FORMAT PAYSAGE */
    @page {
        size: landscape;
        margin: 2cm;
    }
    /* Vous pouvez ajouter d'autres styles personnalisés ici */
    body {
        font-family: "DejaVu Sans", sans-serif;
    }
    code {
        font-family: "DejaVu Sans Mono", monospace;
    }
  </style>
  <title>$title$</title>
</head>
<body>
  $body$
</body>
</html>

portrait: changer landscape en portrait

echo "choisir le .md à convertir en html/pdf"
ls *.md
read fichier
echo "portrait ou paysage"
read orientation
 
pandoc $fichier -o intermediaire.html \
  --~/template=~/tpl/template-$orientation.html \
  --standalone
 
weasyprint intermediaire.html $orientation.pdf
  • info/md2pdf.1769746895.txt.gz
  • Dernière modification : 2026/01/30 05:21
  • de radeff