Hello Magento Friends,

Ever wanted to provide admins with a quick way to download custom PDFs directly from the order view in Magento 2? This blog post will guide you through adding a custom button to achieve the above capability.

This functionality empowers admins to download relevant PDFs without leaving the order view, streamlining order processing. Let’s find out the steps to add custom button to admin sales order view page in order to download PDF.

Steps to Add Custom Button to Download Custom Created PDF Programmatically in Admin Sales Order View in Magento 2:

Step 1: Create di.xml file in the given below path


And then add the code as follows

Step 2: Create a Button.php in the following path


Then include the below-mentioned code

Step 3: Create a routes.xml file in the below-mentioned path


After that, add the below code snippet

Step 4: Create a Controller file in path given below


Then add the code as follows


The admin sales order view page will now have custom button

custom button

Once you click on the button, your custom PDF will be downloaded



By following these steps, you’ve successfully added a custom button to the Admin Sales Order View in Magento 2 that allows for downloading a custom-created PDF. Share the tutorial with your friends, and stay in touch with us.

Happy Coding!

Click to rate this post!
[Total: 0 Average: 0]