I am trying to print logo into custom pdf through controller. I am able to print product name, sku etc.But I don't know how to add store logo. My code is as below. Can anyone please help me to add store logo into custom pdf as I have logo URL but don't know how to insert them. Thanks in advance.
$logoURl = $this->_logo->getLogoSrc(); //logo URL
$productName = $product->getName(); //Product Name
$productSku = $product->getSku(); //Product SKU
$pdf = new \Zend_Pdf();
$page = $pdf->newPage(\Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
$page->setFont(\Zend_Pdf_Font::fontWithName(\Zend_Pdf_Font::FONT_HELVETICA), 20);
$page->drawText($logoURl, 10, 500); //Able to print Logo URL
$page->drawText($productName, 10, 400); //Able to print product name
$page->drawText($productSku, 10, 350); //Able to print product SKU
$pdfData = $pdf->render();
header("Content-Disposition: inline; filename=result.pdf");
header("Content-type: application/x-pdf");
echo $pdfData;
Best Answer
You should use
drawImage
instead ofdrawText
function.Try :