|
|
@ -194,10 +194,10 @@ class JasperServerRequestService implements JasperServerRequestServiceContract
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param string $uri
|
|
|
|
* @param string $uri
|
|
|
|
* @param string|null $pdfFilename
|
|
|
|
* @param string|null $filename
|
|
|
|
* @return string
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function call(string $uri, ?string $pdfFilename = null): string
|
|
|
|
public function call(string $uri, ?string $filename = null): string
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$report = $this->client->reportService()->runReport(
|
|
|
|
$report = $this->client->reportService()->runReport(
|
|
|
|
$uri,
|
|
|
|
$uri,
|
|
|
@ -212,8 +212,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract
|
|
|
|
$this->transformerKey
|
|
|
|
$this->transformerKey
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->format === 'pdf') {
|
|
|
|
if (in_array($this->format, ReportFormatEnum::downloadable())) {
|
|
|
|
$this->setPdfHeader($report, $pdfFilename);
|
|
|
|
$this->setHeader($report, $filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $report;
|
|
|
|
return $report;
|
|
|
@ -221,21 +221,21 @@ class JasperServerRequestService implements JasperServerRequestServiceContract
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param string $report
|
|
|
|
* @param string $report
|
|
|
|
* @param string|null $pdfFilename
|
|
|
|
* @param string|null $filename
|
|
|
|
* @return void
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function setPdfHeader(string $report, ?string $pdfFilename = null)
|
|
|
|
private function setHeader(string $report, ?string $filename = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!$pdfFilename) {
|
|
|
|
if (!$filename) {
|
|
|
|
$pdfFilename = uniqid() . '.pdf';
|
|
|
|
$filename = uniqid() . '.' . $this->format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
header('Cache-Control: must-revalidate');
|
|
|
|
header('Cache-Control: must-revalidate');
|
|
|
|
header('Pragma: public');
|
|
|
|
header('Pragma: public');
|
|
|
|
header('Content-Description: File Transfer');
|
|
|
|
header('Content-Description: File Transfer');
|
|
|
|
header("Content-Disposition: $this->contentDisposition;filename=$pdfFilename");
|
|
|
|
header("Content-Disposition: $this->contentDisposition;filename=$filename");
|
|
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
header('Content-Length: ' . strlen($report));
|
|
|
|
header('Content-Length: ' . strlen($report));
|
|
|
|
header('Content-Type: application/pdf');
|
|
|
|
header('Content-Type: ' . ReportFormatEnum::getMimeType($this->format));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|