Reputation: 3
I am trying to generate the pdf in Codeigniter.I created it successfully but i am not able to put the image in that created pdf using codeigniter.Can you please help me to do this.
I look forward to hearing from you.
Upvotes: 0
Views: 4069
Reputation: 7902
You need to append the document root to you image path.
E.g.
$image = getenv("DOCUMENT_ROOT").'/image_folder/my_image.png';
echo '<img src="'.$image.'" alt="My image" />
If the view is used for both html output and pdf then pass it a variable you can test, and add this if statement to your view;
if ($type == 'html')
{
$root = $this->config->item('base_url');
}
else
{
$root = getenv("DOCUMENT_ROOT").'/';
}
Then the PHP would be;
echo '<img src="'.$root.'image_folder/my_image.png" alt="My image" />';
Upvotes: 1