From ce116fe0a244346afbb33febde68247f9583bed7 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 6 Dec 2011 23:02:14 +0000 Subject: [PATCH] add pdf (not working yet) git-svn-id: http://www.observium.org/svn/observer/trunk@2761 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pdf.php | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 html/pdf.php diff --git a/html/pdf.php b/html/pdf.php new file mode 100644 index 0000000000..fcf603fa47 --- /dev/null +++ b/html/pdf.php @@ -0,0 +1,113 @@ +SetY(-15); + // Set Font + $this->SetFont('helvetica', 'N', 8); + // Set Footer text + $this->Cell(0, 0, 'Created by Observium (www.observium.org)', 0, false, 'L', 0, 'http://www.observium.org/', 0, false, 'M', 'M'); + $this->Cell(10, 0, 'Page '.$this->getAliasNumPAge().' of '.$this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'M', 'M'); + } + } + + // create new PDF document + $pdf = new ObsPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + + // set document security + $protection['permissions'] = array('modify', 'copy', 'annot-forms', 'fill-forms'); + $protection['userpass'] = null; + //$protection['ownerpass'] = "6q49qp783sqo8p3o45q30nno51q01q35"; + $protection['ownerpass'] = str_rot13(md5(str_rot13(pow(rand(), rand(0, 1000))))); + $protection['mode'] = 3; + $protection['pubkey'] = null; + $pdf->SetProtection($protection['permissions'], $protection['userpass'], $protection['ownerpass'], $protection['mode'], $protection['pubkey']); + + // disable header + $pdf->setPrintHeader(false); + + // 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, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); + $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 some language-dependent strings + $pdf->setLanguageArray($l); + + // --------------------------------------------------------- + + // set default font subsetting mode + $pdf->setFontSubsetting(true); + + // Set font + // dejavusans is a UTF-8 Unicode font, if you only need to + // print standard ASCII chars, you can use core fonts like + // helvetica or times to reduce file size. + $pdf->SetFont('dejavusans', '', 10, '', true); + + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + if ($_SESSION['authenticated']) { + if ($type == "billing") { + if ($report == "history") { + include("pages/bill/pdf_history.inc.php"); + } + } + } + + // Print text using writeHTMLCell() + $pdf->writeHTML($html, $ln=true, $fill=false, $reseth=true, $cell=false, $align=''); + + // --------------------------------------------------------- + + // Close and output PDF document + // This method has several options, check the source code documentation for more information. + $pdf->Output($filename, 'I'); + +?>