Skip to content

Instantly share code, notes, and snippets.

@ScullWM
Created November 12, 2013 10:47
Show Gist options
  • Save ScullWM/7428992 to your computer and use it in GitHub Desktop.
Save ScullWM/7428992 to your computer and use it in GitHub Desktop.
public function getPdf($isSecondPage = false, $filename = 'facture')
{
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A3', true, 'UTF-8', false);
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '', '');
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setLanguageArray('fr');
$pdf->SetFont('helvetica', 'B', 20);
$pdf->AddPage();
$pdf->SetFont('helvetica', '', 8);
$pdf->writeHTML($this->content, true, false, false, false, '');
if($isSecondPage===true){
$pdf->AddPage();
$pdf->SetFont('helvetica', '', 8);
$pdf->writeHTML($this->secondPage, true, false, false, false, '');
}
$pdf->Output($filename.'.pdf', 'I');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment