title: How to convert modern HTML to PDF
body: <p>In 2016, the best way to convert HTML files to PDF from the command line was using wkhtmltopdf. Unfortunately, it seems that that is not really maintained anymore. It doesn't support a lot of things like flexbox.</p>
  
  <p>One can use headless chrome/chromium to do it:</p>
  
  <pre>
  chrome --headless --print-to-pdf="path/to/pdf" https://your_url
  </pre>
  
  <p>but that has no options such as margins, paper type, control over header/footer, screen size, etc.</p>
  
  <p>It appears that there is no plan to add those into headless chrome as command line options (one needs to use the dev tools interface):
  <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=603559#c89" rel="noreferrer">https://bugs.chromium.org/p/chromium/issues/detail?id=603559#c89</a></p>
  
  <p>How can one convert HTML files to PDF from the command line that gives control over how the document prints (margins, etc., from above), and supports modern html/css? Of course, once one can convert from the command line, you can also convert using a programming language of your choice.</p>