1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public function exportpdfAction()
{
$idrapport=$_GET['url'];
$orientation=$_GET['orientation'];
$extension='pdf';
$manager= $this->get('session')->get('entitymanager');
$em = $this->getDoctrine()->getManager($manager);
$user=$this->container->get('security.context')->getToken()->getUser();
$user=$em->getRepository('ICMUserBundle:User')->findOneByIdentifiantuser($user->getIdentifiantuser());
$iduser=$user->getId();
$basepath = $this->getRequest()->getBasePath();
$falgun_pdf = '';
$response = new Response();
$result=$this->container->get('icm_api.rapport')->export($iduser,$manager,$basepath,$extension,$idrapport,$falgun_pdf,$response,$orientation);
$rapport=$em->getRepository('ICMReportingBundle:rapports')->find($idrapport);
$nomimage=str_replace(' ','_',$rapport->getTitre()).'.pdf';
$urlpdf=$_SERVER['DOCUMENT_ROOT'].$basepath.'/pdf/'.$nomimage;
$rapportchem = dirname(__FILE__)."/../../../../pdf/";
$response->headers->set('Content-Type', 'application/pdf');
$response->setContent(file_get_contents($rapportchem.$nomimage));
$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-disposition', 'filename='. $nomimage);
echo file_get_content($rapportchem.$nomimage);
return $response;
} |
Partager