0

I am working on Magento 2.2.7 &
need to change font style of shipment pdf
i want to achieve that using preference way of di.xml file how to do that.
which files,function i have to override ?

1

You need to do following things.

  1. create di.xml file into your custom extension at following location.

app\code\Vendor\Extension\etc\adminhtml\di.xml

<?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\Shipment" type="Vendor\Extension\Model\Order\Pdf\Shipment" />
</config>
  1. now create the Shipment.php file at the following location.

app\code\Vendor\Extension\Model\Order\Pdf\Shipment.php

<?php
namespace Vendor\Extension\Model\Order\Pdf;

class Shipment extends \Magento\Sales\Model\Order\Pdf\Shipment
{
    public function getPdf($shipments = [])
    {
        // DO YOUR LOGIC HERE
    }
}
| improve this answer | |
  • thanks man . it worked. multilevel inheritance . :) – Naveen Jain May 8 '19 at 9:54
  • 1
    If answer help you, upvote and accept as solution. So it will help other in community. – Dhiren Vasoya May 8 '19 at 10:41
  • already done bro,please upvote the question xD – Naveen Jain May 10 '19 at 9:36

Your Answer

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

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