I am working on Magento 2.3. I need to change the name of PDF file which is attached in invoice email.

In invoice we have send email button. When we click customer will get invoice email with invoice pdf attachment. I want to change that PDF name. Anyone know from where I can find that name and change ?


1 Answer 1


Reference Link

In this case, I think we need override the invoice admin controller by using preference.

<?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\Controller\Adminhtml\Order\Invoice" 
      type="Vendor\Module\Controller\Adminhtml\Order\Invoice" />

In the custom admin controller, we need to change the name of Pdf file.

public function execute() 
  $invoiceId = $this->getRequest()->getParam('invoice_id');
  return $this->_fileFactory->create(
                    'invoice_00000' . $invoiceId . '.pdf', //<== Change the name here.

Should read more about create method in vendor/magento/framework/App/Response/Http/FileFactory.php

  • I want to chaneg the name in email attachment file. This will change the name there ? Commented Jun 4, 2021 at 11:20
  • I tried this but not working on email. Commented Jun 4, 2021 at 11:29

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.