使用dompdf转换后,背景图像不会在pdf文件中打印

时间:2017-07-29 10:42:02

标签: php html codeigniter pdf

我使用dompdf将html转换为pdf。 Html正在转换为pdf并且正在进行下载。唯一的事情是背景图像不打印。我在codeigniter中这样做。

Html

<div class="container" style="width:85%!important">
  <div class="bgimg" style="width:950px; height:600px; padding:20px; text-align:center; margin-left:20px; margin-top:20px; margin-bottom:20px;">

    <!--<div style="width:950px; height:600px; padding:20px; text-align:center; border: 10px solid #787878">-->

    <span style="font-size:50px; font-weight:bold">Certificate of Completion</span>
    <br><br>
    <span style="font-size:25px"><i>This is to certify that</i></span>
    <br><br>
    <span style="font-size:30px"><b>Name</b></span><br/><br/>
    <span style="font-size:25px"><i>has completed the course</i></span> <br/><br/>
    <span style="font-size:30px">Engineering</span> <br/><br/>
    <span style="font-size:20px">with score of <b>69%</b></span> <br/><br/><br/><br/>


  </div>
</div>

控制器

function download() {
  $user_id = $this - > session - > userdata('user_id');
  $data = array();

  /*  fetch required data from database
   $data['result'] */
  $this - > load - > library('pdf');
  $this - > pdf - > load_view('certificate_template', $data, TRUE);
  $this - > pdf - > setPaper('A4', 'landscape');
  $this - > pdf - > render();
  $this - > pdf - > stream("Certificate.pdf");

}

帮助

?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  

/**
 * CodeIgniter PDF Library
 *
 * Generate PDF's in your CodeIgniter applications.
 *
 * @package			CodeIgniter
 * @subpackage		Libraries
 * @category		Libraries
 * @author			Chris Harvey
 * @license			MIT License
 * @link			https://github.com/chrisnharvey/CodeIgniter-PDF-Generator-Library
 */

require_once(dirname(__FILE__) . '/dompdf/autoload.inc.php');
use Dompdf\Dompdf;

class Pdf extends DOMPDF
{
	/**
	 * Get an instance of CodeIgniter
	 *
	 * @access	protected
	 * @return	void
	 */
	protected function ci()
	{
		return get_instance();
	}

	/**
	 * Load a CodeIgniter view into domPDF
	 *
	 * @access	public
	 * @param	string	$view The view to load
	 * @param	array	$data The view data
	 * @return	void
	 */
	public function load_view($view, $data = array())
	{
		$html = $this->ci()->load->view($view, $data, TRUE);

		$this->load_html($html);
		
	}
}
?>

样式表是

.bgimg { background:url('http://localhost/prodac/assets/css/cer.jpg'); }
怎么解决这个?我已将DOMPDF_ENABLE_REMOTE更改为true。但仍然没有工作。

0 个答案:

没有答案