title: Printing pdf formated receipts using RP327 80mm Thermal Receipt Printer
body: <p>I'm using dompdf to generate pdf formatted receipts which than be printed using <a href="http://www.rongtatech.com/products-look-63.html" rel="nofollow noreferrer">RP327 80mm Thermal Receipt Printer</a>. But printed receipts are not fitting the paper properly. Here is an attached image of printed receipts <a href="https://i.stack.imgur.com/iXwdW.jpg" rel="nofollow noreferrer">pos receipt</a>. 
  Here is my html table which is converted to a pdf file</p>
  
  <pre><code>&lt;?php
  ob_clean();
  $dompdf = new DOMPDF();
  $dompdf-&gt;set_option('default_font', 'Courier');
  
  $customPaper = array(0,0,340,650);
  //$dompdf-&gt;set_paper($customPaper);
  $dompdf-&gt;set_option('enable_css_float',true);
  //$dompdf-&gt;set_paper("A3", "portrait");
  
  $html =' &lt;html&gt;
      &lt;head&gt;&lt;style&gt;
          .table { display: table; width: 100%; border-collapse: collapse; }
          .table-row { display: table-row; }
          .table-cell { display: table-cell; border: 1px solid black; padding: 1em; }
      }
      span {  display: block;  }
      @page table {
        size: 340px 650px;
        margin: 0px;;
      }
  
      .table {
         page: table;
         page-break-after: always;
         font-size: 20px;
      }
      &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div class="table"&gt;
        &lt;div class="table-row"&gt;&lt;div class="table-cell" colspan="3" style="text-align: center"&gt;&lt;img src="../../img/top-logo.png"&gt;&lt;/div&gt;&lt;/div&gt;
          &lt;div class="table-row"&gt;
            &lt;div class="table-cell" &gt;&lt;span&gt;&lt;b&gt; Merchant: &lt;/b&gt; '.$parceldetails['company'].' &lt;/span&gt;&lt;span&gt;&lt;b&gt; Pick Addr: &lt;/b&gt; '.$parceldetails['addr'].' &lt;/span&gt;&lt;span&gt;&lt;b&gt; Mobile: &lt;/b&gt; '.$parceldetails['mobile'].' &lt;/span&gt;&lt;/div&gt;
             &lt;div class="table-cell" style="padding: 0px"&gt;
             &lt;div class="" &gt;Delivery Date:&lt;/div&gt;&lt;br&gt;
             &lt;div class="" style="border-bottom: 1px solid #000000"&gt; '.$parceldetails['r_delivery_time'].' at '.$parceldetails['bytime'].'&lt;/div&gt;
  
             &lt;div class=""&gt;Agent:&lt;/div&gt;&lt;br&gt;
             &lt;div class=""&gt; '.$parceldetails['name'].' &lt;/div&gt;
             &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="table-row"&gt;
            &lt;div class="table-cell" colspan="3" style="text-align: center"&gt; &lt;b style="font-size: larger"&gt;'.$ecr.'&lt;/b&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="table-row"&gt;
             &lt;div class="table-cell" colspan="1"&gt;&lt;span&gt;&lt;b&gt;Customer Name:&lt;/b&gt; '.$parceldetails['r_name'].'&lt;/span&gt;&lt;span&gt;&lt;b&gt; Addr:&lt;/b&gt; '.$parceldetails['r_address'].' &lt;/span&gt;&lt;span&gt;&lt;b&gt; Mobile: &lt;/b&gt; '.$parceldetails['r_mobile'].' &lt;/span&gt;&lt;/div&gt;
             &lt;div class="table-cell" style="padding: 0px"&gt;
                &lt;div class="" style="border-bottom: 2px solid #000000; text-align: center"&gt;&lt;b&gt; '.$parceldetails['paymentmethod'].' &lt;/b&gt;&lt;/div&gt;
                &lt;div class="" style="text-align: center"&gt;&lt;b&gt; '.$parceldetails['product_price'].' BDT &lt;/b&gt;&lt;/div&gt;
             &lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="table-row"&gt;
             &lt;div class="table-cell"  style="text-align: center"&gt; '.genarateQRCode($data).' &lt;/div&gt;
              &lt;div class="table-cell"  style="padding: 0px"&gt;
                &lt;div class="" style="border-bottom: 2px solid #000000; text-align: center; height:63px"&gt; Delivered &lt;/div&gt;
                &lt;div class="" style="text-align: center; min-height:63px"&gt; Cancel &lt;/div&gt;
             &lt;/div&gt;
              &lt;div class="table-cell" style="padding: 0px"&gt;
                &lt;div class="" style="border-bottom: 2px solid #000000; text-align: center; height:63px"&gt;&amp;#160;&lt;/div&gt;
                &lt;div class="" style="text-align: center; min-height:63px""&gt;&lt;/div&gt;
             &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="table-row"&gt;
            &lt;div class="table-cell" colspan="3"&gt;
            &lt;b style="margin-top:50px; margin-bottom:-10px; border-bottom: 1px solid #000000; font-size:10px; margin-left:10px"&gt;Agent signature&lt;/b&gt;
            &lt;b style="margin-top:50px; margin-bottom:-10px; border-bottom: 1px solid #000000; font-size:10px; margin-left:50px"&gt;Receiver signature&lt;/b&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;';
        $html .='&lt;table class="table"&gt;
        &lt;tr&gt;
         &lt;td colspan="3"&gt;&lt;img src="../../img/top-logo.png"&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td rowspan="2" colspan="2"&gt;&lt;span&gt;&lt;b&gt; Merchant: &lt;/b&gt; '.$parceldetails['company'].' &lt;/span&gt;&lt;span&gt;&lt;b&gt; Pick Addr: &lt;/b&gt; '.$parceldetails['addr'].' &lt;/span&gt;&lt;span&gt;&lt;b&gt; Mobile: &lt;/b&gt; '.$parceldetails['mobile'].' &lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;D. Date&lt;span&gt;'.$parceldetails['r_delivery_time'].'&lt;/span&gt;&lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr&gt;
          &lt;td&gt;Agent&lt;span&gt;'.$parceldetails['name'].'&lt;/span&gt;&lt;/td&gt;
         &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td colspan="3"&gt;'.$ecr.'&lt;/td&gt;
        &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td rowspan="2" colspan="2"&gt;&lt;span&gt;&lt;b&gt;Customer Name:&lt;/b&gt; '.$parceldetails['r_name'].'&lt;/span&gt;&lt;span&gt;&lt;b&gt; Addr:&lt;/b&gt; '.$parceldetails['r_address'].' &lt;/span&gt;&lt;span&gt;&lt;b&gt; Mobile: &lt;/b&gt; '.$parceldetails['r_mobile'].' &lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;b&gt;'.$parceldetails['paymentmethod'].'&lt;/b&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
           &lt;td&gt;&lt;b&gt;'.$parceldetails['product_price'].' BDT&lt;/b&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td rowspan="2" colspan="1"&gt;'.genarateQRCode($data).'&lt;/td&gt;
          &lt;td&gt;Delivered&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
           &lt;td&gt;Cancel&lt;/td&gt;
           &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td colspan="3"&gt;&amp;nbsp&lt;/td&gt;
        &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td colspan="3"&gt;Agent Signature Receiver Signature&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/body&gt;
      &lt;/html&gt;';
  $dompdf-&gt;load_html($html);
  $dompdf-&gt;render();
  $dompdf-&gt;stream("dompdf_out.pdf", array('Attachment' =&gt; 0));
  &lt;?&gt;
  </code></pre>