title: How can I change paper size in headless Chrome --print-to-pdf
body: <p>I am using headless Chrome to export html documents to pdf</p>
  
  <pre><code>google-chrome --headless --disable-gpu --print-to-pdf='output_path' 'url'
  </code></pre>
  
  <p><strong>How can I change paper size in generated pdf?</strong></p>
  
  <p>I have control on both Chrome parameters and html.</p>
  
  <p>I always get US Letter.</p>
  
  <p>There are no documented command-line options for this.</p>
  
  <p>I've tried setting CSS: <code>@page {size: A4;}</code>. No effect in headless mode, but works when I hit <kbd>Ctrl</kbd>+<kbd>P</kbd> in normal mode (option to choose paper size for <code>Save as pdf</code> disappears, exported pdf has A4 page size).</p>
  
  <p>I've tried this on Chrome versions 59, 60 and 61 on Ubuntu 16.04.</p>