root/trunk/app/views/helpers/fpdf.php

Revision 758, 2.0 kB (checked in by aarkerio, 5 weeks ago)

Update models

Line 
1<?php 
2/**
3*    Chipotle Software TM 2002-2008
4*   @author: Manuel Montoya     manuel<arroba>mononeurona<punto>org
5*   @license: GPLv3
6*/
7App::import('Vendor', 'fpdf/myfpdf');
8
9class FpdfHelper extends Helper {
10
11  public  $initialized = false;
12  public  $pdf  = null; 
13  /**
14   * Allows you to change the defaults set in the FPDF constructor
15   *
16   * @param string $orientation page orientation values: P, Portrait, L, or Landscape    (default is P)
17   * @param string $unit values: pt (point 1/72 of an inch), mm, cm, in. Default is mm
18   * @param string $format values: A3, A4, A5, Letter, Legal or a two element array with the width and height in unit given in $unit
19   */
20  public function __construct($orientation='P',$unit='mm',$format='Letter') 
21  { 
22    $this->pdf = new myFPDF(null, null, $format);
23    $this->pdf->SetFont('Arial','B',10);
24  }
25   
26  public function setData($data)
27  {
28    $string  =  utf8_decode($data);  // UTF-8
29    // Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, boolean fill [, mixed link]]]]]]])
30    $this->pdf->Cell(0,3,$string,0,1,'L');
31    $this->pdf->Ln(2);
32  }
33
34  public function newPage()
35  {
36     $this->pdf->AddPage();
37  }
38  /**
39   * Allows you to control how the pdf is returned to the user, most of the time in CakePHP you probably want the string
40   *
41   * @param string $name name of the file.
42   * @param string $destination where to send the document values: I, D, F, S
43   * @return string if the $destination is S
44   */
45  public function fpdfOutput($name = 'page.pdf', $destination = 'D') 
46  {
47    // I: send the file inline to the browser. The plug-in is used if available.
48    //    The name given by name is used when one selects the "Save as" option on the link generating the PDF.
49    // D: send to the browser and force a file download with the name given by name.
50    // F: save to a local file with the name given by name.
51    // S: return the document as a string. name is ignored.
52    return $this->pdf->Output($name, $destination);
53  }
54}
55?>
Note: See TracBrowser for help on using the browser.