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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| public function printAction($id)
{
$em = $this->getDoctrine()->getManager();
$user = $em->getRepository('MonprojetBundle:Compte')->find($id);
$emp=$em->getRepository('MonprojetBundle:Employe')->findOneByIdCpt($id);
$pdf = $this->get('tcpdf');
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('');
$pdf->SetTitle('TCPDF Example');
$pdf->SetSubject('TCPDF Example');
$pdf->SetKeywords('TCPDF, example');
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set font
$pdf->SetFont('times', '', 12);
$pdf->AddPage();
// set some text to print
/* $txt = <<<EOD
TCPDF Example 1
Default page header and footer are disabled using setPrintHeader() and setPrintFooter() methods.
EOD;*/
$html =$this->get('templating')->render('MonprojetBundle:Admini:apercu_employe.html.twig', array(
'user' => $user,
'emp' => $emp,
));
$content=$html->getContent();
$pdf -> writeHTML($content);
$pdf->Output('example_002.pdf', 'I');
return $this->redirect($this->generateUrl('homepage'));
} |
Partager