Pimcore\Controller\Action\Admin\Printpage::pdfDownloadAction PHP Метод

pdfDownloadAction() публичный Метод

public pdfDownloadAction ( )
    public function pdfDownloadAction()
    {
        $document = Document\Printpage::getById(intval($this->getParam("id")));
        if (empty($document)) {
            throw new \Exception("Document with id " . $this->getParam("id") . " not found.");
        }
        if (file_exists($document->getPdfFileName())) {
            if ($this->getParam("download")) {
                header("Content-Type: application/pdf");
                header("Content-Disposition: attachment; filename=" . $document->getKey() . '.pdf');
                while (@ob_end_flush()) {
                }
                flush();
                readfile($document->getPdfFileName());
                exit;
            } else {
                header("Content-Type: application/pdf");
                while (@ob_end_flush()) {
                }
                flush();
                readfile($document->getPdfFileName());
                exit;
            }
        } else {
            throw new \Exception("File does not exist");
        }
    }