public function getPDFResponse($template, $variables = [], $params = []) { $markup = $this->getPDFMarkup($template, $variables, $params); $response = new \Zend\Http\Response(); $response->setContent($markup); $headers = new \Zend\Http\Headers(); $filename = isset($params['fileName']) ? 'filename=' . $params['fileName'] . '.pdf' : 'filename=' . $this->defaultFileName; $headers->addHeaders(['Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; ' . $filename . '', 'Content-Transfer-Encoding' => 'binary', 'Content-Length' => strlen($markup), 'Accept-Ranges' => 'bytes']); $response->setHeaders($headers); return $response; }