title: How to center absolutely positioned elements in css for a pdf
body: <p>I'm trying to center the names(#box2) and the topic(#box1) on top of an image.</p>
  
  <pre><code>&lt;?php require_once('seminar_config.php'); ?&gt;
  
  &lt;a href="print.certificate.php"&gt;Print&lt;/a&gt;
  
  &lt;body&gt;
  &lt;?php
  $participants = $db-&gt;get_results("SELECT participant FROM tbl_participants WHERE state=1");
  $topics = $db-&gt;get_results("SELECT topic FROM tbl_topics");
  if(!empty($participants)){
  ?&gt;
  &lt;?php ob_start(); ?&gt;
  &lt;div id="container"&gt;
  &lt;img src="certificate.jpg"/&gt;
  &lt;?php foreach($topics as $a=&gt;$b){ ?&gt;
  &lt;?php foreach($participants as $k=&gt;$v){ ?&gt;
      &lt;img src="certificate.jpg"/&gt;
      &lt;div id="box1" class="common"&gt;&lt;?php echo $b-&gt;topic; ?&gt;&lt;/div&gt;
      &lt;div id="box2" class="common"&gt;&lt;?php echo $v-&gt;participant; ?&gt;&lt;/div&gt;
  &lt;?php } ?&gt;
  &lt;?php } ?&gt;  
  &lt;/div&gt;
  &lt;?php $_SESSION['certificates'] = ob_get_contents(); ?&gt;
  &lt;?php ob_flush(); ?&gt;    
  &lt;?php } ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>And here's the script that creates the pdf:</p>
  
  <pre><code>&lt;?php require_once('html2pdf/html2pdf.class.php'); ?&gt;
  &lt;?php
  $html2pdf = new HTML2PDF('L', 'A4', 'en');
  $html2pdf-&gt;writeHTML('&lt;style&gt;
  
      #box1{  
          margin-top: 350px;
      }
  
      #box2{  
          margin-top: 200px;
      }
  
      .common{
          height: 20px;
          left: 630px;
          right: 630px;
          text-align: center;
          position: absolute;
          left: 0;
          top: 0;
          font-size:20px;
      }
  &lt;/style&gt;'.
  
  $_SESSION['certificates']);
  $html2pdf-&gt;Output('random.pdf');
  ?&gt;
  </code></pre>
  
  <p>I have no problem with the center positioning of the names and topic if I'm not using html2pdf to generate pdf files. 
  But if I use html2pdf everything is ruined. Please help me center things in css when using html2pdf. </p>