Ejemplo n.º 1
0
 public function printAction(Request $request)
 {
     $printer = new RecordHelper\Printer($this->app, $request);
     $layout = $request->request->get('lay');
     foreach ($printer->get_elements() as $record) {
         $this->getDataboxLogger($record->get_databox())->log($record, \Session_Logger::EVENT_PRINT, $layout, '');
     }
     $PDF = new PDFExport($this->app, $printer->get_elements(), $layout);
     $response = new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
     $response->headers->set('Pragma', 'public', true);
     $response->setMaxAge(0);
     return $response;
 }
Ejemplo n.º 2
0
 public function connect(Application $app)
 {
     $app['controller.prod.printer'] = $this;
     $controllers = $app['controllers_factory'];
     $controllers->post('/', function (Application $app) {
         $printer = new RecordHelper\Printer($app, $app['request']);
         return $app['twig']->render('prod/actions/printer_default.html.twig', ['printer' => $printer, 'message' => '']);
     });
     $controllers->post('/print.pdf', function (Application $app) {
         $printer = new RecordHelper\Printer($app, $app['request']);
         $layout = $app['request']->request->get('lay');
         foreach ($printer->get_elements() as $record) {
             $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_PRINT, $layout, '');
         }
         $PDF = new PDFExport($app, $printer->get_elements(), $layout);
         $response = new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
         $response->headers->set('Pragma', 'public', true);
         $response->setMaxAge(0);
         return $response;
     })->bind('prod_printer_print');
     return $controllers;
 }