LeadStar
LeadStar

Reputation: 152

How to fix image is not showing on PDF using PHPSpreadsheet?

I used PHPSpreadsheet(https://github.com/PHPOffice/PhpSpreadsheet) for generating Excel and PDF. I added image on first cell and it is showing well on excel but not for PDF. How to fix this issue?

$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing();
    $drawing->setName('PhpSpreadsheet logo');
    $drawing->setPath('../upload/14.png');
    $drawing->setHeight(50);
    $drawing->setCoordinates('A1');
    $drawing->setOffsetX(30);
    $drawing->setWorksheet($spreadsheet->getActiveSheet());

Upvotes: 1

Views: 2073

Answers (1)

Dave
Dave

Reputation: 5191

Instead of using a relative path to your image use the full path instead.

Change

'../upload/14.png'

to something like (modifying for your specific setup)

'/home/html/upload/14.png'

Upvotes: 1

Related Questions