pdfCreditmemo = $pdfCreditmemo; $this->fileFactory = $fileFactory; $this->dateTime = $dateTime; $this->collectionFactory = $collectionFactory; parent::__construct($context, $filter); } /** * @param AbstractCollection $collection * @return ResponseInterface * @throws \Exception * @throws \Zend_Pdf_Exception */ public function massAction(AbstractCollection $collection) { $pdf = $this->pdfCreditmemo->getPdf($collection); $fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true]; return $this->fileFactory->create( sprintf('creditmemo%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')), $fileContent, DirectoryList::VAR_DIR, 'application/pdf' ); } }