I am using php and mpdf to generate a particular pdf. I have some pie diagrams in the pdf. For that I am using pChart. I am generating pie diagrams dynamically for rendering in pdf.
In my pdf all the static images are rendered properly, but no dynamically generated pie diagrams.
This one(static) works,
<div class="chart">
<?php echo CHtml::image(Yii::app()->baseUrl.'/images/color-block2.png', 'Logo screenshot', array('class' => 'logo_image')); ?>
</div>
But not this(dynamic)
<div class="chart">
<?php echo CHtml::image(Yii::app()->baseUrl.'/images/pie.png', 'Logo screenshot', array('class' => 'logo_image')); ?>
</div>
Ps: I am using Yii url rules for a clean url for pie diagram.
When i rendered the pdf_template as html, both images are rendered properly.
How can i implement dynamic images using mpdf without the $mpdf->Image() method.
I suspect i cannot use the $mpdf->Image() while generating a pdf from html.
Update:
After
$mPDF->showImageErrors = true;
I'm getting
mPDF error: IMAGE Error (http://csrt.dev/images/pie.png): Could not find image file
Base64 encoded the image and embedded it in a <img> tag.
<div class="chart">
<img src="data:image/png;base64,xx5t.." />
</div>
I had the same problem using Yii, and found this to be the solution, however for other Yii/PHP users out there, you have to use base64_encode(your file contents) to get the part after base64, in the tag.
for example:
base64_encode(file_get_contents("../images/folder16.gif"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With