title: TCPDF does not render external CSS
body: <p>I am trying to generate PDFs using <code>TCPDF</code> library. So far, I am able to generate the PDF files using PHP code. Although it does not render external CSS and result becomes useless as  without CSS the document is not readable.</p>
  
  <p>Following is my code in the controller:</p>
  
  <pre><code> public function generate_pdf() {
  
          $this-&gt;load-&gt;model('rosters', 'roster');
  
          $data = array();
  
          $data['start_date'] = isset($_POST['fortnightStartDate']) ?
              date("Y-m-d", strtotime(getFortnightStartDate($_POST['fortnightStartDate']))) :
              getFortnightStartDate();
          $cid = $_POST['cid'];
          $wno = $_POST['wno'];
  
  
          $data['no']=$wno;
  
          $startDate = strtotime($data['start_date']);
  
          $data['schedule'] = $this-&gt;roster-&gt;getShifts($cid, $data);
  
          $data['startDate'] = $startDate;
  
  
          $listing = $this-&gt;load-&gt;view('roster/roster_pdf', $data, true);
  
  
          /**
   * Creates an example PDF TEST document using TCPDF
   * @package com.tecnick.tcpdf
   * @abstract TCPDF - Example: XHTML + CSS
   * @author Nicola Asuni
   * @since 2010-05-25
   */
  
  // Include the main TCPDF library (search for installation path).
  require_once(APPPATH.'libraries/tcpdf/tcpdf.php');
  
  // create new PDF document
  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  
  // set document information
  $pdf-&gt;SetCreator(PDF_CREATOR);
  $pdf-&gt;SetAuthor('Nicola Asuni');
  $pdf-&gt;SetTitle('TCPDF Example 061');
  $pdf-&gt;SetSubject('TCPDF Tutorial');
  $pdf-&gt;SetKeywords('TCPDF, PDF, example, test, guide');
  
  // set default header data
  $pdf-&gt;SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING);
  
  // set header and footer fonts
  $pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  $pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  
  // set default monospaced font
  $pdf-&gt;SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  
  // set margins
  $pdf-&gt;SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  $pdf-&gt;SetHeaderMargin(PDF_MARGIN_HEADER);
  $pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);
  
  // set auto page breaks
  $pdf-&gt;SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  
  // set image scale factor
  $pdf-&gt;setImageScale(PDF_IMAGE_SCALE_RATIO);
  
  // set some language-dependent strings (optional)
  if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
      require_once(dirname(__FILE__).'/lang/eng.php');
      $pdf-&gt;setLanguageArray($l);
  }
  
  // ---------------------------------------------------------
  
  // set font
  $pdf-&gt;SetFont('helvetica', '', 10);
  
  // add a page
  $pdf-&gt;AddPage();
  
  
  $pdf-&gt;writeHTML($listing, true, false, true, false, '');
  
  //Close and output PDF document
  $pdf-&gt;Output('TEST.pdf', 'F');  
  
      }
  </code></pre>
  
  <p>I am passing the <code>$listing</code> variable which holds the data that needs to be included in the PDF. The data is printing fine but without CSS. If I try to include the external CSS it pops up the error.</p>
  
  <p><strong>Code to include external css</strong></p>
  
  <pre><code>$listing. = '&lt;style&gt;'.file_get_contents(base_url("styles/style.css")).'&lt;/style&gt;';
  </code></pre>
  
  <p>I try to include this line of code below the <code>$listing</code> variable but it generates following error:</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Warning
  
  Message: array_merge(): Argument #2 is not an array
  
  Filename: tcpdf/tcpdf.php
  
  Line Number: 16375
  </code></pre>
  
  <p>Is there any other way I can load the external CSS ??
  Any help will be highly appreciated.</p>