Created
April 9, 2015 08:02
-
-
Save miznokruge/6450154a4908e6cc54b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::import('Vendor', 'xtcpdf'); | |
set_time_limit(300000); | |
$pdf = new XTCPDF('P', PDF_UNIT, 'A4', true, 'UTF-8', false); | |
$applicationoc_name = 'Sales Report'; | |
$filename = time() . '.pdf'; | |
//---------------------------------------------------------- config start --------------------------------------------------------------------------- | |
$pdf->namaorg = $application['company_name']; | |
$pdf->telp = $application['company_phone']; | |
$pdf->fax = $application['company_fax']; | |
$pdf->nama_aplikasi = $application['app_name']; | |
$pdf->alamat = $application['company_address']; | |
$pdf->email = $application['company_email']; | |
$pdf->website = $application['company_website']; | |
$pdf->logo = '../webroot/img/Alert.png'; | |
$pdf->SetCreator(PDF_CREATOR); | |
$pdf->SetAuthor('Mizno Kruge'); | |
$pdf->SetTitle('TCPDF Example 048'); | |
$pdf->SetSubject('TCPDF Tutorial'); | |
$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); | |
//$pdf->SetHeaderData($logo,20, '',''); | |
// set default header data | |
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); | |
// set image scale factor | |
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); | |
#$pdf->SetDisplayMode($zoom='fullpage', $layout='TwoColumnRight', $mode='UseNone'); | |
// set header and footer fonts | |
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); | |
$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, 28, 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->setPrintFooter(false); | |
//$pdf->setPrintHeader(false); | |
$pdf->AddPage(); | |
#$img_file = '../webroot/img/bg/6.jpg'; | |
#$pdf->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0); | |
$pdf->SetFont('helvetica', '', 10); | |
//---------------------------------------------------------- config end --------------------------------------------------------------------------- | |
$header = '<h1><center>Project: ' . $ps['Project']['name'] . '</center></h1>' | |
. '<p>Category:<br> ' . $ps['Category']['name'] . '</p>' | |
. '<p>Description:<br>' . $ps['Project']['description'] . '</p><br pagebreak="true"/>'; | |
for ($i = 1; $i <= count($fs); $i++) { | |
$bMargin = $pdf->getBreakMargin(); | |
// get current auto-page-break mode | |
$auto_page_break = $pdf->getAutoPageBreak(); | |
// disable auto-page-break | |
$pdf->SetAutoPageBreak(false, 0); | |
$pdf->SetAutoPageBreak($auto_page_break, $bMargin); | |
$body.= '<h2><center>' . $fs[$i] . '</center></h2><br>' . "<ol>"; | |
foreach ($ps['BusinessModel'] as $bm) { | |
if ($bm['feature_id'] == $i) { | |
$body.= '<li>' | |
. '<h3>' . $bm['title'] . '</h3>' | |
. '' . $bm['description'] . '' | |
. '</li>'; | |
} | |
} | |
$body.= '</ol>' | |
. '<br pagebreak="true"/>'; | |
} | |
$html = $header . $body; | |
if ($dom[$key]['tag'] AND isset($dom[$key]['attribute']['pagebreak'])) { | |
// check for pagebreak | |
if (($dom[$key]['attribute']['pagebreak'] == 'true') OR ( $dom[$key]['attribute']['pagebreak'] == 'left') OR ( $dom[$key]['attribute']['pagebreak'] == 'right')) { | |
// add a page (or trig AcceptPageBreak() for multicolumn mode) | |
$this->checkPageBreak($this->PageBreakTrigger + 1); | |
} | |
if ((($dom[$key]['attribute']['pagebreak'] == 'left') AND ( ((!$this->rtl) AND ( ($this->page % 2) == 0)) OR ( ($this->rtl) AND ( ($this->page % 2) != 0)))) | |
OR ( ($dom[$key]['attribute']['pagebreak'] == 'right') AND ( ((!$this->rtl) AND ( ($this->page % 2) != 0)) OR ( ($this->rtl) AND ( ($this->page % 2) == 0))))) { | |
// add a page (or trig AcceptPageBreak() for multicolumn mode) | |
$this->checkPageBreak($this->PageBreakTrigger + 1); | |
} | |
} | |
$pdf->writeHTML($html, true, false, true, false, ''); | |
//$pdf->lastPage(); | |
$pdf->Output($filename, 'I'); | |
die(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment