I wrote the below code to show rectangle in pdf file

        $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0.92)); 
        $page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.92));
        $page->drawRectangle($x, $oldY+20, ($pageWidth/2)-50, $this->y-10);
        $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
        $page->setLineColor(new \Zend_Pdf_Color_GrayScale(0));

AND Output is enter image description here

But I need round corners in rectangle how can I do this in Magento 2 Zend pdf.I wanna output like this

Expected output: enter image description here

1 Answer 1


I think you may use some tricky like

// draw rounded rectangle like
$page->drawRoundedRectangle($x1, $y1, $x2, $y2, $radius);
// draw classic rectangle over rounded rectangle
$page->drawRectangle($x1 - 15, $y1, $x2, $y2, $radius);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.