title: PHP mPDF with cut command - printing too much paper
body: <p>I have a printer receipt called "Start STP 100" and my website creates a PDF with a receipt format using the mPDF library.</p>
  
  <p>The following code is my class to generate a PDF:</p>
  
  <pre><code>class printdoc
  {
      private $width;
  
      public function __construct()
      {
          require('mPDF/mpdf.php');
  
          $this-&gt;width = 80;
  
          // Default values
          $this-&gt;mPDF = new mPDF('utf-8', array($this-&gt;width, 1000), 9, 'Segoe UI', 5, 5, 0, 0, 5, 5, 'P');
          $this-&gt;mPDF-&gt;setAutoTopMargin = 'pad';
      }
  
      public function write($html, $url)
      {
          $this-&gt;mPDF-&gt;WriteHTML($html[0]);
          $this-&gt;mPDF-&gt;page   = 0;
          $this-&gt;mPDF-&gt;state  = 0;
          unset($this-&gt;mPDF-&gt;pages[0]);
  
          $p = 'P';
          // At this point the Y size is set according to the dimensions of the PDF
          // So the value '1000' set in the __construct() has no effect.
          $this-&gt;mPDF-&gt;_setPageSize(array($this-&gt;width, $this-&gt;mPDF-&gt;y), $p);
  
          foreach($html as $content)
          {
              $this-&gt;mPDF-&gt;addPage();
              $this-&gt;mPDF-&gt;WriteHTML($content);
          }
  
          $this-&gt;mPDF-&gt;Output($url);
      }
  
      public function create($data)
      {
          $html  = '&lt;html&gt;';
          $html .= '  &lt;head&gt;&lt;/head&gt;';
          $html .= '  &lt;body&gt;';
          $html .=        $this-&gt;header($data);
          $html .=        $this-&gt;body($data);
          $html .=        $this-&gt;footer($data);
          $html .= '  &lt;/body&gt;';
          $html .= '&lt;/html&gt;';
  
          return $html;
      }
  }
  </code></pre>
  
  <p>Now in order to create the receipt and save it, I have this function:</p>
  
  <pre><code>function printreceipt($data)
  {
      require('printdoc.php');
  
      $file = 'test-receipt.pdf';
      $html = $this-&gt;printdoc-&gt;create($data);
  
      $this-&gt;printdoc-&gt;write($html, $file);
  }
  </code></pre>
  
  <p>What happens is that the file generated when seen with Chrome PDF Viewer has the correct dimensions (in terms of width and height), but when sent to the printer it prints too much paper.</p>
  
  <p>Basically this is the size of the PDF (when viewed on a browser):</p>
  
  <pre><code> ---
  |   |
  |   |
  |   |
   ---
  </code></pre>
  
  <p>And this is the size of the paper when printed:</p>
  
  <pre><code> ---
  |   |
  |   |
  |   |
  |   |
  |   |
  |   |
  |   |
  |   |
  |   |
  |   |
   ---
  </code></pre>
  
  <p>Is there any way to force mPDF to cut the file or write any command after my <code>html</code> in order to the printer interpret and cut?</p>