0

I want to change the design and layout of my packing-slip pdf print-outs to make a simple and clean print for the employes to work through.

Is there any extension / tutorial / anything else which shows how to make this possible ?

3 Answers 3

4

To edit the packing list, or any other PDF docs such as invoice you need to override the files contained within

Magento\Sales\Model\Order\Pdf

For example if wanted to add the price to the packing list

<?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\Items\Shipment\DefaultShipment"
                type="Example\Sales\Model\Order\Pdf\Items\Shipment\DefaultShipment"/>

</config>

Then copy the file "Magento\Sales\Model\Order\Pdf\Items\Shipment\DefaultShipment" to your app/code file, change the name spacing to match the XML above and add the following on around line number 81

 // draw item Prices
        $i = 0;
        $prices = $this->getItemPricesForDisplay();
        $feedPrice = 395;
        $feedSubtotal = $feedPrice + 70;
        $feedTax = $feedSubtotal + 70;
        foreach ($prices as $priceData) {
            if (isset($priceData['label'])) {
                // draw Price label
                $lines[$i][] = ['text' => $priceData['label'], 'feed' => $feedPrice, 'align' => 'right'];
                // draw Subtotal label
                $lines[$i][] = ['text' => $priceData['label'], 'feed' => $feedSubtotal, 'align' => 'right'];
                $i++;
            }
            // draw Price
            $lines[$i][] = [
                'text' => $priceData['price'],
                'feed' => $feedPrice,
                'font' => 'bold',
                'align' => 'right',
            ];
            // draw Subtotal
            $lines[$i][] = [
                'text' => $priceData['subtotal'],
                'feed' => $feedSubtotal,
                'font' => 'bold',
                'align' => 'right',
            ];
            $i++;
        }

        // draw Tax
        $lines[0][] = [
            'text' => $order->formatPriceTxt($item->getTaxAmount()),
            'feed' => $feedTax,
            'font' => 'bold',
            'align' => 'right',
        ];
1
  • Thanks its works but in $item = $this->getItem(); some data are missing like subtotal, tax etc. can you tell me how can I fetch all the data in $item ? Commented Oct 8, 2018 at 5:39
0

You can take a look at this module https://www.vnecoms.com/magento2-pdf-invoice-pro.html. This module allow you customize your template directly inside backend. Use editor allow you can create template in a few clicks. Support magento 2.2.x

-1

I don't know if you already did this, but for future people that come across this, here is a video that somehow explains it. https://www.youtube.com/watch?v=_baegIF0v48&feature=youtu.be

1
  • This is a very bad procedure as the files will be overwritten with future Magento updates.
    – SoCix
    Commented Oct 11, 2020 at 14:09

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.