cell() public method

The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text. If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.
See also: setFont()
See also: setDrawColor()
See also: setFillColor()
See also: setLineWidth()
See also: addLink()
See also: newLine()
See also: multiCell()
See also: write()
See also: setAutoPageBreak()
public cell ( float $width, float $height, string $text = '', mixed $border, integer $ln, string $align = '', integer $fill, string $link = '' )
$width float Cell width. If 0, the cell extends up to the right margin.
$height float Cell height.
$text string String to print.
$border mixed Indicates if borders must be drawn around the cell. The value can be either a number: - 0: no border (default) - 1: frame or a string containing some or all of the following characters (in any order): - L: left - T: top - R: right - B: bottom
$ln integer Indicates where the current position should go after the call. Possible values are: - 0: to the right (default) - 1: to the beginning of the next line - 2: below Putting 1 is equivalent to putting 0 and calling {@link newLine()} just after.
$align string Allows to center or align the text. Possible values are: - L or empty string: left (default) - C: center - R: right
$fill integer Indicates if the cell fill type. Possible values are: - 0: transparent (default) - 1: painted
$link string URL or identifier returned by {@link addLink()}.
コード例 #1
0
ファイル: StoryPdf.php プロジェクト: horde/horde
 public function run()
 {
     extract($this->_params, EXTR_REFS);
     $driver = $GLOBALS['injector']->getInstance('Jonah_Driver');
     if (!$story_id) {
         try {
             $story_id = $GLOBALS['injector']->getInstance('Jonah_Driver')->getLatestStoryId($channel_id);
         } catch (Exception $e) {
             $this->_exit($e->getMessage());
         }
     }
     try {
         $story = $driver->getStory($story_id, !$browser->isRobot());
     } catch (Exception $e) {
         $this->_exit($e->getMessage());
     }
     // Convert the body from HTML to text if necessary.
     if (!empty($story['body_type']) && $story['body_type'] == 'richtext') {
         $story['body'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($story['body'], 'html2text');
     }
     // Set up the PDF object.
     $pdf = new Horde_Pdf_Writer(array('format' => 'Letter', 'unit' => 'pt'));
     $pdf->setMargins(50, 50);
     // Enable automatic page breaks.
     $pdf->setAutoPageBreak(true, 50);
     // Start the document.
     $pdf->open();
     // Start a page.
     $pdf->addPage();
     // Publication date.
     if (!empty($story['published_date'])) {
         $pdf->setFont('Times', 'B', 14);
         $pdf->cell(0, 14, $story['published_date'], 0, 1);
         $pdf->newLine(10);
     }
     // Write the header in Times 24 Bold.
     $pdf->setFont('Times', 'B', 24);
     $pdf->multiCell(0, 24, $story['title'], 'B', 1);
     $pdf->newLine(20);
     // Write the story body in Times 14.
     $pdf->setFont('Times', '', 14);
     $pdf->write(14, $story['body']);
     // Output the generated PDF.
     $browser->downloadHeaders($story['title'] . '.pdf', 'application/pdf');
     echo $pdf->getOutput();
 }
コード例 #2
0
ファイル: WriterTest.php プロジェクト: jubinpatel/horde
 public function testTextColor()
 {
     $pdf = new Horde_Pdf_Writer();
     $pdf->setInfo('CreationDate', $this->fixtureCreationDate());
     $pdf->setCompression(false);
     $pdf->open();
     $pdf->addPage();
     $pdf->setFont('Helvetica', 'B', 48);
     $pdf->setDrawColor('rgb', 50, 0, 0);
     $pdf->setTextColor('rgb', 0, 50, 0);
     $pdf->setFillColor('rgb', 0, 0, 50);
     $pdf->cell(0, 50, 'Hello Colors', 1, 0, 'C', 1);
     $actual = $pdf->getOutput();
     $expected = $this->fixture('text_color');
     $this->assertEquals($expected, $actual);
 }