'Typo3 PDF only viewable if Logged into Backend
I run into a Problem with PDF creation on Typo3.
I have a Website with a lot of different Tables. Some of them should be available as PDF Exports.
The best way (for me) was to use a Custom ViewHelper with a special Controller and everything.
This works IF Iam loggend in into the Backend. It will not Work if Iam loggen in as a FE User. In this case the PDF is opened with a warning that it could not be displayed...
Is there a Setting I need to change?
Edit:
This is the ViewHelper
class PDFViewHelper extends AbstractViewHelper {
public function initializeArguments(){
[...]
}
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
[...]
}
private static function generateReport(){
{
$file = new FPDF();
[...]
return $file->Output();
}
}
The Template
{namespace exsv=basicNamespace\ViewHelpers}
<exsv:PDF [...]/>
And the ActionController
class PDFAPIController extends ActionController{
protected $viewFormatToObjectNameMap = array(
'pdf' => 'basicNamespace\Classes\ViewHelper\PDFView'
);
public function createPDFAction(){
/** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $typoScriptFrontendController */
$typoScriptFrontendController = $GLOBALS['TSFE'];
$typoScriptFrontendController->setContentType('application/pdf');
$this->response->setHeader('Content-Transfer-Encoding', 'binary');
$this->response->setHeader('Content-type', 'application/pdf');
[...]
$this->view->setControllerContext($this->getControllerContext());
}
}
Edit2:
Some further investigation directed me to the followeing line.
$typoScriptFrontendController->setContentType('application/pdf');
everything is fine until I comment this out in the controller.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|