Create a PDF

Create a PDF

  • Published by
    Yannick Berges
  • Last modified
    19 April 2021
  • Voting
    Average rating
  • Favourites
  • Concerns
    Component Template
  • Since Version
  • Up to date
  • Profile concerned
    Webdesigner, Developer

Thanks to charlynancy  for this tuto

Downlaod TCPDF Library and install it
Duplicate a template for editing file
Edit item.php and load modular code

Use this code after

endif; ?>


setPrintHeader(false); // set footer fonts $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set font $pdf->SetFont('dejavusans', '', 10); // add a page $pdf->AddPage(); // create some HTML content $html = '

HTML Example

your content
blabla more content //here display a flexicontent field_resume
' . $item->fields['field_resume']->display; // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); //Close and output PDF document, save pdf in /images/ $pdf->Output($_SERVER['DOCUMENT_ROOT'] . 'SOUS_REPERTOIRE/images/' . $this->item->alias . '.pdf', 'F'); //becaurefull adapt the good folder to your config 'SOUS_REPERTOIRE/images/' //ex 'SOUS_REPERTOIRE/images/' //complet url /var/www/default/SOUS_REPERTOIRE/images // Now we will add a link to the pdf echo 'PDF'; ?>
© 2018 Flexicontent. All Rights Reserved.