Skip to content

Magento 2 Mass Action PDF open into new tab

  • I have create one custom mass action at order grid using this mass action download one custom pdf.
  • Now, when I click on this mass action option pdf is automatically download but did not open into new tab.
  • So anyone guide us how to do this ?

create mass action using below code.

  1. app/code/vendor/extension/view/adminhtml/ui_component/sales_order_grid.xml
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <listingToolbar name="listing_top">
        <massaction name="listing_massaction">
            <settings>
                <actions>
                    <action name="1">
                        <type>print_invoice</type>
                        <label translate="true">Invoice Print</label>
                        <url path="printpicking/print/invoice"/>
                    </action>
                </actions>
            </settings>
        </massaction>
    </listingToolbar>
</listing>
  • At controller file I tried below way but using this code pdf open into same window instead of download but I want to open into new tab.
  1. app/code/vendor/extension/ControllerAdminhtmlPrintInvoice.php

     $resultRaw->setHeader('Content-Disposition', 'inline; filename="' . $fileName . '"');