Refresh page after download PDF in custom module magento 2. When the download is complete, the page is not f5. Please help me.
My function
public function createPDF(\Magento\Framework\Event\Observer $observer, $product, $printedAttribute) {
$nameProduct = $product->getName();
$attribute = $product->getData($printedAttribute);
$qty = $observer->getQty();
$orderNumber = $observer->getOrdernumber();
$deliOrderNumber = $observer->getDeliordernumber();
$pdf = new \Zend_Pdf();
$page = $pdf->newPage(\Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
$style = new \Zend_Pdf_Style();
$style->setLineColor(new \Zend_Pdf_Color_Rgb(0, 0, 0));
$font = \Zend_Pdf_Font::fontWithName(\Zend_Pdf_Font::FONT_TIMES);
$style->setFont($font, 15);
$page->setStyle($style);
$x = 30;
$this->y = 850 - 100; //print table row from page top – 100px
//Draw table header row’s
$style->setFont($font, 16);
$page->setStyle($style);
$page->drawRectangle(30, $this->y + 10, $page->getWidth() - 30, $this->y + 70, \Zend_Pdf_Page::SHAPE_DRAW_STROKE);
$style->setFont($font, 15);
$page->setStyle($style);
$page->drawText(__("Cutomer Details"), $x + 5, $this->y + 50, 'UTF-8');
$style->setFont($font, 11);
$page->setStyle($style);
$page->drawText(__("Name : %1", "John Smith"), $x + 5, $this->y + 33, 'UTF-8');
$page->drawText(__("Email : %1", "[email protected]"), $x + 5, $this->y + 16, 'UTF-8');
$style->setFont($font, 12);
$page->setStyle($style);
$page->drawText(__("PRODUCT_NAME"), $x + 30, $this->y - 10, 'UTF-8');
$page->drawText(__("COUNT"), $x + 150, $this->y - 10, 'UTF-8');
$page->drawText(__("ORDER_NUMBER"), $x + 250, $this->y - 10, 'UTF-8');
$page->drawText(__("DELIVERY_NOTE_ID"), $x + 380, $this->y - 10, 'UTF-8');
$page->drawText(__($printedAttribute), $x + 30, $this->y - 80, 'UTF-8');
$style->setFont($font, 10);
$page->setStyle($style);
$page->drawText($nameProduct, $x + 30, $this->y - 30, 'UTF-8');
$page->drawText($qty, $x + 150, $this->y - 30, 'UTF-8');
$page->drawText($orderNumber, $x + 250, $this->y - 30, 'UTF-8');
$page->drawText($deliOrderNumber, $x + 380, $this->y - 30, 'UTF-8');
$page->drawText($attribute, $x + 70, $this->y - 80, 'UTF-8');
$page->drawRectangle(30, $this->y - 62, $page->getWidth() - 30, $this->y + 10, \Zend_Pdf_Page::SHAPE_DRAW_STROKE);
$page->drawRectangle(30, $this->y - 62, $page->getWidth() - 30, $this->y - 100, \Zend_Pdf_Page::SHAPE_DRAW_STROKE);
$style->setFont($font, 15);
$page->setStyle($style);
$page->drawText(__("Text"), ($page->getWidth() / 2) - 50, $this->y - 200);
$fileName = 'name.pdf';
$this->fileFactory->create(
$fileName, $pdf->render(), \Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR, // this pdf will be saved in var directory with the name example.pdf
'application/pdf'
);
return $this->_redirect('*/*/index');
}