public function downloadpdf()
    {
        if (!$this->owner->data()->config()->get('pdf_export')) {
            return false;
        }

        // We only allow producing live pdf. There is no way to secure the draft files.
        Versioned::set_stage(Versioned::LIVE);

        $path = $this->owner->data()->getPdfFilename();
        if (!file_exists($path)) {
            $this->owner->generatePDF();
        }

        return HTTPRequest::send_file(file_get_contents($path), basename($path), 'application/pdf');
    }