Images and Yii Framwork

507 views
Skip to first unread message

Jason George

unread,
Apr 2, 2010, 3:35:15 AM4/2/10
to dompdf
I've just started trying to integrate dompdf with Yii. I can generate
pdf files, however, the images are broken links. I'm pasting my view
controller below. Any pointers would be great.

<?php
Yii::import('application.vendors.*');
require_once('digitaljunkies/dompdf/dompdf_config.inc.php');
spl_autoload_unregister(array('YiiBase','autoload'));
// this makes the php engine unhappy, likely incorrect syntax
//spl_autoload_register(array('DOMPDF_autoload','autoload'));
spl_autoload_register(array('YiiBase','autoload'));

class RecruitmentController extends CController
{
/**
* @var string specifies the default action to be 'list'.
*/
public $defaultAction='show';

/**
* Shows a particular model.
*/
public function actionShow()
{
$this->render('show');
}

/**
* Generates a printable recruitment pdf.
*/
public function actionPrint()
{
$html =
'<html><body>'.
'<div style="width:5in; height:5in; background-color:green;">'.
getcwd().'<br>'.
'localhost/images/ispies/recruitment/russia1.jpg'.
'<img src="'.Yii::app()->request->baseUrl.'/images/ispies/
recruitment/russia1.jpg" alt="iSpies" border=0>'.
'</div>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->base_path = Yii::app()->request->baseUrl;
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
}
}

BrianS

unread,
Apr 5, 2010, 5:22:26 PM4/5/10
to dompdf
Yii::app()->request->baseUrl pulls the current domain (I'm not
familiar with the Yii framework)? If so your code looks fine. You
might check to make sure DOMPDF has write permissions to the temporary
directory specified by DOMPDF_TEMP_DIR. Also, have you tried echoing
out your $html var to confirm the image path?
Reply all
Reply to author
Forward
0 new messages