Example #1
15
 public function Footer()
 {
     $txt = '';
     if ($this->footer_param['form']) {
         $txt = HTML2PDF::textGET('pdf05');
     }
     if ($this->footer_param['date'] && $this->footer_param['heure']) {
         $txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf03');
     }
     if ($this->footer_param['date'] && !$this->footer_param['heure']) {
         $txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf01');
     }
     if (!$this->footer_param['date'] && $this->footer_param['heure']) {
         $txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf02');
     }
     if ($this->footer_param['page']) {
         $txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf04');
     }
     if (strlen($txt) > 0) {
         $txt = str_replace('[[date_d]]', date('d'), $txt);
         $txt = str_replace('[[date_m]]', date('m'), $txt);
         $txt = str_replace('[[date_y]]', date('Y'), $txt);
         $txt = str_replace('[[date_h]]', date('H'), $txt);
         $txt = str_replace('[[date_i]]', date('i'), $txt);
         $txt = str_replace('[[date_s]]', date('s'), $txt);
         $txt = str_replace('[[current]]', $this->PageNo(), $txt);
         $txt = str_replace('[[nb]]', '{nb}', $txt);
         parent::SetY(-11);
         $this->setOverline(false);
         $this->SetFont('helvetica', 'I', 8);
         $this->Cell(0, 10, $txt, 0, 0, 'R');
     }
 }
Example #2
3
 /**
  * Generates Pdf from html
  *
  * @return string raw pdf data
  */
 public function output()
 {
     //TCPDF often produces a whole bunch of errors, although there is a pdf created when debug = 0
     //Configure::write('debug', 0);
     $TCPDF = new \TCPDF($this->_Pdf->orientation(), 'mm', $this->_Pdf->pageSize());
     $TCPDF->AddPage();
     $TCPDF->writeHTML($this->_Pdf->html());
     return $TCPDF->Output('', 'S');
 }
 function __construct()
 {
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $this->pdf = $pdf;
     $this->widths = new stdClass();
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetAutoPageBreak(false);
     $pdf->AddPage();
 }
Example #4
1
 /**
  * initPdf - initialize TCPDF with current setting
  *
  * @return void
  */
 private function initPdf()
 {
     if (empty($this->pdfEngine)) {
         $this->pdfEngine = new TCPDF($this->pageOrientation, $this->unit, $this->pageSize, true, 'UTF-8', false);
         if (isset($this->pdfAuthor)) {
             $this->pdfEngine->SetAuthor($this->pdfAuthor);
         }
         if (isset($this->pdfTitle)) {
             $this->pdfEngine->SetTitle($this->pdfTitle);
         }
         if (isset($this->pdfSubject)) {
             $this->pdfEngine->SetSubject($this->pdfSubject);
         }
         if (isset($this->pdfKeywords)) {
             $keywords = is_array($this->pdfKeywords) ? implode(', ', $this->pdfKeywords) : (string) $this->pdfKeywords;
             $this->pdfEngine->SetKeywords($keywords);
         }
         if (!empty($this->pdfCreator)) {
             $this->pdfEngine->SetCreator($this->pdfCreator);
         }
         if (!empty($this->fontFamily)) {
             $this->pdfEngine->SetFont($this->fontFamily, $this->fontStyle, $this->fontSize);
         }
         if (!empty($this->monoFontFamily)) {
             $this->pdfEngine->SetDefaultMonospacedFont($this->monoFontFamily);
         }
         if (!empty($this->leftMargin)) {
             $this->pdfEngine->SetMargins($this->leftMargin, $this->topMargin, $this->rightMargin);
         }
         if (empty($this->bottomMargin)) {
             $this->bottomMargin = PDF_MARGIN_BOTTOM;
         }
         $this->pdfEngine->SetAutoPageBreak(true, $this->bottomMargin);
     }
 }
 private function Rotate($type, $x = -1, $y = -1)
 {
     if ($type == "") {
         $angle = 0;
     } elseif ($type == "Left") {
         $angle = 90;
     } elseif ($type == "Right") {
         $angle = 270;
     } elseif ($type == "UpsideDown") {
         $angle = 180;
     }
     if ($x == -1) {
         $x = $this->pdf->getX();
     }
     if ($y == -1) {
         $y = $this->pdf->getY();
     }
     if ($this->angle != 0) {
         $this->pdf->_out('Q');
     }
     $this->angle = $angle;
     if ($angle != 0) {
         $angle *= M_PI / 180;
         $c = cos($angle);
         $s = sin($angle);
         $cx = $x * $this->pdf->k;
         $cy = ($this->pdf->h - $y) * $this->pdf->k;
         $this->pdf->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy));
     }
 }
Example #6
1
    function loadPdf($article_id)
    {
        $this->load->library('pdf');
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // Add a page
        $pdf->AddPage();
        // $html = '<div class="col-lg-12"> <h1 class="page-header">News</h1></div>';
        //$data['article'] = $this->articles->get_article($article_id);
        //$html= $this->load->view('output_pdf', $data);
        $data = $this->articles->get_article($article_id);
        $html = '<body style="height: 100%;margin-bottom: 30px;"><div style="height: 30px;">News<br/>Title:' . $data['title'] . '</div><div id="content"><center><img src="./././images/' . $data['photo'] . '"' . 'width="100" height="150" align="center"></center><br/>' . $data['text'] . '[</div><div style="height: 30px;position: absolute;
		    bottom: 0;">[Author Name]:' . $data['user_name'] . '- [TimeStamp]:' . $data['curr_time'] . '</div>';
        $pdf->writeHTML($html, true, false, true, false, '');
        ob_clean();
        $pdf->Output('news_001.pdf', 'I');
    }
 public function Footer()
 {
     if (defined('WPPTOPDFENH_CUSTOM_FOOTER')) {
         $this->writeHTMLCell(WPPTOPDFENH_FOOTER_WIDTH, WPPTOPDFENH_FOOTER_MIN_HEIGHT, WPPTOPDFENH_FOOTER_X, WPPTOPDFENH_FOOTER_Y, WPPTOPDFENH_CUSTOM_FOOTER, WPPTOPDFENH_FOOTER_BORDER, 0, WPPTOPDFENH_FOOTER_FILL, true, WPPTOPDFENH_FOOTER_ALIGN, WPPTOPDFENH_FOOTER_PAD);
     } else {
         // call parent footer method for default footer
         parent::Footer();
     }
 }
Example #8
0
 /**
  * Returns the usable page height, which is the page height without top and bottom margin.
  *
  * @param \TCPDF $pdf
  * @param int $page
  * @return float
  */
 public static function getPageContentHeight(\TCPDF $pdf, $page)
 {
     // get total height of the page in user units
     $totalHeight = $pdf->getPageHeight($page) / $pdf->getScaleFactor();
     $margin = $pdf->getMargins();
     return $totalHeight - $margin['bottom'] - $margin['top'];
 }
 public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
 {
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('league-gothic', '', 100, '', true);
     $pdf->writeHTMLCell(200, 200, 18, 35, $this->buildHTML('h1', $title), 0, 1, 0);
     $pdf->SetFont('league-gothic', '', 70, '', true);
     $pdf->writeHTMLCell(80, 200, 130, 135, $this->buildHTML('p', $slogan, 80), 0, 1, 0);
     $pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
     $pdf->writeHTMLCell(120, 100, 18, 241, $this->buildHTML('h2', $name, 30), 0, 1, 0);
     $pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
     $pdf->writeHTMLCell(175, 100, 18, 254, $this->buildHTML('p', $details, 20), 0, 1, 0);
 }
Example #10
0
 /**
  *  Save PHPExcel to file
  *
  *  @param     string     $pFilename   Name of the file to save as
  *  @throws    PHPExcel_Writer_Exception
  */
 public function save($pFilename = null)
 {
     $fileHandle = parent::prepareForSave($pFilename);
     //  Default PDF paper size
     $paperSize = 'LETTER';
     //    Letter    (8.5 in. by 11 in.)
     //  Check for paper size and page orientation
     if (is_null($this->getSheetIndex())) {
         $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
         $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
         $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
     } else {
         $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
         $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
         $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
     }
     //  Override Page Orientation
     if (!is_null($this->getOrientation())) {
         $orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
     }
     //  Override Paper Size
     if (!is_null($this->getPaperSize())) {
         $printPaperSize = $this->getPaperSize();
     }
     if (isset(self::$paperSizes[$printPaperSize])) {
         $paperSize = self::$paperSizes[$printPaperSize];
     }
     //  Create PDF
     $pdf = new TCPDF($orientation, 'pt', $paperSize);
     $pdf->setFontSubsetting(false);
     //    Set margins, converting inches to points (using 72 dpi)
     $pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72);
     $pdf->SetAutoPageBreak(true, $printMargins->getBottom() * 72);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->AddPage();
     //  Set the appropriate font
     $pdf->SetFont($this->getFont());
     $pdf->writeHTML($this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter());
     //  Document info
     $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
     $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
     $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
     $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
     $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
     //  Write to file
     fwrite($fileHandle, $pdf->output($pFilename, 'S'));
     parent::restoreStateAfterSave($fileHandle);
 }
 public function download($id)
 {
     $book = Book::with(array('chapter' => function ($query) {
         $query->orderBy('order', 'asc');
     }, 'chapter.element' => function ($query) {
         $query->orderBy('order', 'asc');
     }))->where("id", "=", $id)->get();
     $view = View::make('pdf/result', array("book" => $book));
     $pdf = new TCPDF();
     $pdf->AddPage();
     $pdf->writeHTML($view, true, false, true, false, '');
     $filename = public_path() . '/pdf/test.pdf';
     $pdf->output($filename, 'F');
     return Response::download($filename);
 }
  /**
   * Draws a filled rectangle at x1,y1 with width w and height h
   *
   * See {@link Style::munge_color()} for the format of the color array.
   *
   * @param float $x1
   * @param float $y1
   * @param float $w
   * @param float $h
   * @param array $color
   */
  function filled_rectangle($x1, $y1, $w, $h, $color) {

    $this->_set_fill_color($color);

    // FIXME: ugh, need to handle styles here
    $this->_pdf->rect($x1, $y1, $w, $h, "F");
  }
Example #13
0
 /**
  * get the last absolute Y
  *
  * @access protected
  * @return float $y
  */
 protected function _getLastAbsoluteY()
 {
     for ($k = count($this->table) - 1; $k >= 0; $k--) {
         if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
     }
     return $this->_pdf->gettMargin();
 }
Example #14
0
 function __construct($options)
 {
     $defaults = array('orientation' => 'P', 'unit' => 'mm', 'format' => 'A4', 'unicode' => true, 'encoding' => "UTF-8");
     $options = is_array($options) ? am($defaults, $options) : $defaults;
     extract(am($defaults, $options));
     parent::__construct($orientation, $unit, $format, $unicode, $encoding);
 }
Example #15
0
 /**
  * @param string $pageOrientation the pageOrientation, like "Portrait" or "Landscape". Standard is Protrait.
  * @param string $unit the measurement of the pdf-Site, like "cm", "mm", "pt" or "in". Standard: cm.
  * @param string $pageFormat the Format of the Page, like "A4". Standard: A4.
  */
 public function __construct($pageOrientation = "Portrait", $unit = "cm", $pageFormat = "A4")
 {
     parent::__construct($pageOrientation, $unit, $pageFormat);
     $this->_htmlCode = '';
     $this->_tempVarSurroundPattern = '';
     $this->_tempDirName = 'kuwasysPdf';
 }
Example #16
0
 /**
  * Initialize 
  *
  */
 function __construct($params = array())
 {
     $orientation = 'P';
     $unit = 'mm';
     $format = 'A4';
     $unicode = true;
     $encoding = 'UTF-8';
     $diskcache = false;
     if (isset($params['orientation'])) {
         $orientation = $params['orientation'];
     }
     if (isset($params['unit'])) {
         $unit = $params['unit'];
     }
     if (isset($params['format'])) {
         $format = $params['format'];
     }
     if (isset($params['encoding'])) {
         $encoding = $params['encoding'];
     }
     if (isset($params['diskcache'])) {
         $diskcache = $params['diskcache'];
     }
     # initialize TCPDF
     parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache);
 }
Example #17
0
	public function __construct($websiteName, $prettyDate, $description, $language)
	{
		parent::__construct();
		$this->websiteName = $websiteName;
		$this->prettyDate = $prettyDate;
		$this->description = $description;
		
		switch($language)
		{
			case 'zh-tw':
			case 'ja':
				$reportFont = 'msungstdlight';
				break;
			
			case 'zh-cn':
				$reportFont = 'stsongstdlight';
			break;
			
			case 'ko':
				$reportFont = 'hysmyeongjostdmedium';
				break;
			
			case 'ar':
				$reportFont = 'almohanad';
				break;
				
			case 'en':
			default:
				$reportFont = 'dejavusans';
				break;
		}
		$this->reportFont = $reportFont;
	}
Example #18
0
 function __construct($options = array())
 {
     $default = array('orientation' => PDF_PAGE_ORIENTATION, 'unit' => PDF_UNIT, 'format' => PDF_PAGE_FORMAT, 'unicode' => true, 'encoding' => 'UTF-8');
     $options = array_merge($default, $options);
     extract($options);
     parent::__construct($orientation, $unit, $format, $unicode, $encoding, false);
 }
Example #19
0
 /**
  * __construct
  *
  * @param array $options Array of options.
  *
  * @return void
  */
 public function __construct($options)
 {
     $this->options(array_merge($this->_defaultOptions, $options));
     $options = $this->options();
     parent::__construct($options['orientation'], $options['unit'], $options['format'], $options['unicode'], $options['encoding'], $options['diskcache']);
     mb_internal_encoding('UTF-8');
     $this->SetCreator($options['creator']);
     $this->SetAuthor($options['author']);
     $this->SetTitle($options['title']);
     $this->SetSubject($options['subject']);
     $this->SetKeywords($options['keywords']);
     // lang
     $this->setLanguageArray($options['language']);
     //set auto page breaks
     $this->SetAutoPageBreak(true, $options['footer']['margin']);
     // set font
     $this->SetFont($options['font'], '', $options['font_size']);
     $this->SetCellPadding(2);
     // margins
     $this->SetMargins($options['margin']['left'], $options['margin']['top'], $options['margin']['right'], true);
     if (empty($options['header'])) {
         $this->SetPrintHeader(false);
     } else {
         $this->SetHeaderMargin($options['header']['margin']);
     }
     if (empty($options['footer'])) {
         $this->SetPrintFooter(false);
     } else {
         $this->SetFooterMargin($options['footer']['margin']);
     }
 }
Example #20
0
 function __construct($filename, array $data)
 {
     parent::__construct();
     $this->setFileName($filename);
     $this->setData($data);
     $this->init();
     $this->setup();
 }
Example #21
0
 /**
  * Return XObjects Dictionary.
  *
  * Overwritten to add additional XObjects to the resources dictionary of TCPDF
  *
  * @return string
  */
 protected function _getxobjectdict()
 {
     $out = parent::_getxobjectdict();
     foreach ($this->_tpls as $tplIdx => $tpl) {
         $out .= sprintf('%s%d %d 0 R', $this->tplPrefix, $tplIdx, $tpl['n']);
     }
     return $out;
 }
Example #22
0
 function _endpage()
 {
     if ($this->angle != 0) {
         $this->angle = 0;
         $this->_out('Q');
     }
     parent::_endpage();
 }
function pdfSetup()
{
    $pdf = new TCPDF("P", "in", "Letter", true, 'UTF-8', false);
    // set document information
    $pdf->SetCreator("ChapR Order Processing System");
    $pdf->SetAuthor('The ChapR');
    $pdf->SetTitle('Packing List');
    $pdf->SetSubject('Order Packing List');
    $pdf->SetKeywords('ChapR, order');
    // remove default header/footer
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    $pdf->SetAutoPageBreak(true, 0);
    $pdf->SetMargins(0, 0, 0, 0, true);
    $pdf->SetFont('helvetica', '', 14, '', true);
    $pdf->AddPage();
    return $pdf;
}
Example #24
0
 /**
  * Prints the page header.
  * @public
  */
 public function Header()
 {
     parent::Header();
     if (!empty($this->header_path)) {
         $this->SetFont('helvetica', '', 7);
         $this->y = 19;
         $this->Cell(0, 0, $this->header_path, 0, 1, 'R', false, '', 0, false, 'T', 'M');
     }
 }
 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8')
 {
     parent::__construct($orientation, $unit, $format, $unicode, $encoding);
     $this->SetFont('', '', 10);
     // SalesPlatform.ru begin
     //$this->setFontFamily('times');
     $this->setFontFamily('helvetica');
     // SalesPlatform.ru end
 }
Example #26
0
 /**
  *
  *
  * @param string $orientation
  * @param string $unit
  * @param string $format
  * @param bool|true $unicode
  * @param string $encoding
  * @param bool|false $diskcache
  * @param bool|false $pdfa
  */
 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa = false)
 {
     if (!class_exists('TCPDF', FALSE)) {
         // Load SwiftMailer
         require Kohana::find_file('vendor', 'tcpdf/tcpdf');
     }
     parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);
     // TODO:
 }
Example #27
0
 /**
  *	Constructor
  * @param string $orientation page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li></ul>
  * @param string $unit User measure unit. Possible values are:<ul><li>pt: point</li><li>mm: millimeter (default)</li><li>cm: centimeter</li><li>in: inch</li></ul><br />A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.
  * @param mixed $format The format used for pages. It can be either one of the following values (case insensitive) or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by unit).<ul><li>4A0</li><li>2A0</li><li>A0</li><li>A1</li><li>A2</li><li>A3</li><li>A4 (default)</li><li>A5</li><li>A6</li><li>A7</li><li>A8</li><li>A9</li><li>A10</li><li>B0</li><li>B1</li><li>B2</li><li>B3</li><li>B4</li><li>B5</li><li>B6</li><li>B7</li><li>B8</li><li>B9</li><li>B10</li><li>C0</li><li>C1</li><li>C2</li><li>C3</li><li>C4</li><li>C5</li><li>C6</li><li>C7</li><li>C8</li><li>C9</li><li>C10</li><li>RA0</li><li>RA1</li><li>RA2</li><li>RA3</li><li>RA4</li><li>SRA0</li><li>SRA1</li><li>SRA2</li><li>SRA3</li><li>SRA4</li><li>LETTER</li><li>LEGAL</li><li>EXECUTIVE</li><li>FOLIO</li></ul>
  * @param boolean $unicode TRUE means that the input text is unicode (default = true)
  * @param boolean $diskcache if TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
  * @param String $encoding charset encoding; default is UTF-8
  */
 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8', $diskcache = false)
 {
     global $pdfpref;
     //Call parent constructor
     parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache);
     //Initialization
     $this->setCellHeightRatio(1.25);
     // Should already be the default
 }
 private function getPdfData()
 {
     $pdf = new \TCPDF();
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetFont('times', 'BI', 12);
     $pdf->AddPage();
     $pdf->Write(0, 'Fichier pdf', '', 0, 'C', true, 0, false, false, 0);
     return $pdf->Output('fichier.pdf', 'S');
 }
 function output($html, $title = 'document', $pFilename = 'doc.pdf')
 {
     require_once '../classes/PHPExcel/Shared/PDF/tcpdf.php';
     require_once "../classes/Settings.php";
     require_once "../classes/SettingsQuery.php";
     // Create PDF
     $pdf = new TCPDF('P', 'pt', 'A4');
     $pdf->SetMargins(56.7, 56.7);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->setTitle($title);
     $pdf->AddPage();
     // Set the appropriate font
     $setQ = new SettingsQuery();
     $setQ->connect();
     if ($setQ->errorOccurred()) {
         $setQ->close();
         displayErrorPage($setQ);
     }
     $setQ->execSelect();
     if ($setQ->errorOccurred()) {
         $setQ->close();
         displayErrorPage($setQ);
     }
     $set = $setQ->fetchRow();
     $pdf->setFont($set->getFontNormal());
     $pdf->writeHTML($html);
     $pdf->SetTitle($title);
     return $pdf->output($pFilename, 'S');
 }
Example #30
-6
 public function Footer()
 {
     $this->SetFont('helvetica', '', 10);
     parent::Footer();
     $this->Cell(0, 5, "", 0, 1, 'L', 0, '', 0, false, 'M', 'M');
     $this->Cell(0, 8, "Report generated with Open-LIMS (" . date("dS M Y H:i") . ")", 0, 1, 'L', 0, '', 0, false, 'M', 'M');
 }