{"action":"opened","issue":{"url":"https://api.github.com/repos/tasmanianfox/MpdfPortBundle/issues/24","repository_url":"https://api.github.com/repos/tasmanianfox/MpdfPortBundle","labels_url":"https://api.github.com/repos/tasmanianfox/MpdfPortBundle/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/tasmanianfox/MpdfPortBundle/issues/24/comments","events_url":"https://api.github.com/repos/tasmanianfox/MpdfPortBundle/issues/24/events","html_url":"https://github.com/tasmanianfox/MpdfPortBundle/issues/24","id":169293100,"number":24,"title":"Not able to download pdf","user":{"login":"sivakaza-volyty","id":18112982,"avatar_url":"https://avatars.githubusercontent.com/u/18112982?v=3","gravatar_id":"","url":"https://api.github.com/users/sivakaza-volyty","html_url":"https://github.com/sivakaza-volyty","followers_url":"https://api.github.com/users/sivakaza-volyty/followers","following_url":"https://api.github.com/users/sivakaza-volyty/following{/other_user}","gists_url":"https://api.github.com/users/sivakaza-volyty/gists{/gist_id}","starred_url":"https://api.github.com/users/sivakaza-volyty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivakaza-volyty/subscriptions","organizations_url":"https://api.github.com/users/sivakaza-volyty/orgs","repos_url":"https://api.github.com/users/sivakaza-volyty/repos","events_url":"https://api.github.com/users/sivakaza-volyty/events{/privacy}","received_events_url":"https://api.github.com/users/sivakaza-volyty/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-04T05:18:45Z","updated_at":"2016-08-04T05:18:45Z","closed_at":null,"body":"I have a custom action (generate pdf) in my sonata admin. below is my code, If i remove the download related code then the browser is rendering pdf perfectly. But Failed to download the file. \r\n\r\n`public function generatePdfAction(){\r\n\r\n          $request = $this->getRequest();\r\n          $id = $request->get($this->admin->getIdParameter());\r\n\r\n          $object = $this->admin->getObject($id);\r\n\r\n          if (!$object) {\r\n              throw $this->createNotFoundException(sprintf('unable to find the object with id : %s', $id));\r\n          }\r\n\r\n          $this->admin->checkAccess('edit', $object);\r\n\r\n          $this->admin->setSubject($object);\r\n\r\n          $datagrid = $this->admin->getDatagrid();\r\n          $formView = $datagrid->getForm()->createView();\r\n\r\n          $em = $this->getDoctrine()->getManager();\r\n          $orderItems = $em->getRepository('AppBundle:OrderItem')->getOrderItemsOfMerchant($object->getMerchant(), $object->getStartDate(), $object->getEndDate() );\r\n\r\n          $orderItemsTotal = $em->getRepository('AppBundle:OrderItem')->getOrderItemsTotal($orderItems, $object->getMerchant()->getId());\r\n\r\n        define('_MPDF_TTFONTDATAPATH','downloads/payout/');\r\n\r\n        $html = $this->renderView('AppBundle:PayoutAdmin:pdf.html.twig', array(\r\n            'action' => 'Generate Pdf',\r\n            'object' => $object,\r\n            'form'   => $formView,\r\n            'orderItems' => $orderItems,\r\n            'orderItemsTotal' => $orderItemsTotal,\r\n            'elements' => $this->admin->getShow(),\r\n        ), null);\r\n\r\n        $fileName = $object->getMerchant() . '_' . $object->getStartDate()->format('m-d-y') . '_to_' . $object->getEndDate()->format('m-d-y');\r\n\r\n        $mpdfService = $this->get('tfox.mpdfport');\r\n        //return $mpdfService->generatePdfResponse(mb_convert_encoding($html, 'UTF-8', 'UTF-8'));\r\n\r\n        return new Response($mpdfService->generatePdf(mb_convert_encoding($html, 'UTF-8', 'UTF-8')),\r\n            array(\r\n                'Content-Type' => 'application/pdf',\r\n                'Content-Disposition' => sprintf('attachment; filename=\"'.$fileName.'\"')\r\n            )\r\n        );\r\n\r\n    }`\r\n\r\ngetting the following error\r\n\r\n`Unable to find template \"\" (looked into: /home/user/projects/myproject/app/Resources/views, /home/user/projects/myproject/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form, /home/user/projects/myproject/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views).\r\n500 Internal Server Error - InvalidArgumentException\r\n1 linked Exception: Twig_Error_Loader »`"}}
{"actor":{"display_login":"sivakaza-volyty"}}