I am trying to override the fontsize value for pdfslip file in my module. The pdfslip files can be found in admin under sales->invoices->actions. The function that I am interested in is drawLineBlocks in app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php.

I created a module and made the following di.xml under /vendor/MY/MODULE/etc/adminhtml like this

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Sales\Model\Order\Pdf\AbstractPdf" type="My\MODULE\Model\Order\Pdf\AbstractPdf" />

and I created AbstarctPdf.php under /vendor/MY/MODULE/Model/Order/Pdf and copied the whole public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSettings = []) in it like this


    namespace MY\MODULE\Model\Order\Pdf;

    class AbstarctPdf

        public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSettings = [])
            foreach ($draw as $itemsProp) { ....
            foreach ($lines as $line) {
                $maxHeight = 0;
                foreach ($line as $column) {
                    $fontSize = empty($column['font_size']) ? 10 : $column['font_size'];
                    if (!empty($column['font_file'])) { ....

The part that I am interested in changing it is $fontSize = empty($column['font_size']) ? 10 : $column['font_size'];.

Changing the font size from 10 to 16 won't work . and Magento won't consider this change. Anyone can help me? I can't find my mistake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.