I am creating a pdf file with dompdf. In the file is a logo .png image with background transparent. When the file is created it renders the image background black and foreground white. Which is not correct. Can someone help to rectify this?
public function downloadPdf($id)
{
$application = FertilAppUser::application($id);
$schedule = FertilAppUser::schedule($id);
$fertiluser = FertilAppUser::detail($id);
$publicPath = public_path('/');
$view = false;
// Generate file name
$filename = $this->makeSafe($application[0]->fname . '_' . $application[0]->bname);
$pdf = PDF::loadView('admin.fertil.schedule.pdf', compact('application', 'schedule', 'fertiluser', 'view'))->setPaper('a4', 'landscape');
return $pdf->download($filename . '_Bemesting_Skedule.pdf');
}
Here is the pdf html image path:
<img src="{{ asset('images/logo.png') }}" alt="Logo" style="width: 120px; height:66px;"/>
I also tried public_path('images/logo.png')
and './images/logo.png'
. This did not work. I also tried using a .jpg file with alpha channel removed with no change in rendering a color photo.
What is strange though is that on my localhost the image is rendered correctly but on my shared hosting provider's server this incorrect image rendering persists. When I logOutputFile it gives:
<span style='color: #000' title='Frames'> 242</span><span style='color: #009' title='Memory'> 20480.00 KB</span><span style='color: #900' title='Time'> 233.81 ms</span><span title='Quirksmode'> <span style='color: #d00'> ON</span></span><br />