Beispiel #1
0
<?php

//create file
$fp = fopen('hello.pdf', 'w');
if (!$fp) {
    echo "Error: could not create the PDF file";
    exit;
}
// start the pdf document
$pdf = pdf_open($fp);
pdf_set_info($pdf, "Creator", "pdftest.php");
pdf_set_info($pdf, "Author", "Luke Welling and Laura Thomson");
pdf_set_info($pdf, "Title", "Hello World (PHP)");
// US letter is 11" x 8.5" and there are 72 points per inch
pdf_begin_page($pdf, 8.5 * 72, 11 * 72);
pdf_add_outline($pdf, 'Page 1');
$font = pdf_findfont($pdf, 'Times-Roman', 'host', 0);
pdf_setfont($pdf, $font, 24);
pdf_set_text_pos($pdf, 50, 700);
// write text
pdf_show($pdf, 'Hello,world!');
pdf_continue_text($pdf, '(says PHP)');
// end the document
pdf_end_page($pdf);
pdf_close($pdf);
fclose($fp);
// display a link to download
echo "download the pdf <a href = 'hello.pdf'>here</a>";
?>
    
Beispiel #2
0
        $title = $album['album'];
    } else {
        $title = $album['artist'] . ' - ' . $album['album'];
    }
    // $title = iconv(NJB_DEFAULT_CHARSET, 'UTF-8', $title);
    pdf_setfont($pdf, $font, 4);
    pdf_save($pdf);
    pdf_rotate($pdf, 90);
    pdf_set_text_pos($pdf, 2, -4.5);
    // y, -x
    pdf_show($pdf, $title);
    pdf_restore($pdf);
    // Restore rotate
    pdf_save($pdf);
    pdf_rotate($pdf, -90);
    pdf_set_text_pos($pdf, -116, 151 - 4.5);
    // -y, x
    pdf_show($pdf, $title);
    pdf_restore($pdf);
    // Restore rotate
    $hash_data .= '-' . $text . '-' . $title;
}
//  +------------------------------------------------------------------------+
//  | PDF front cover                                                        |
//  +------------------------------------------------------------------------+
$x0 = 44 - $x0;
$y0 = 160 - $y0;
pdf_translate($pdf, $x0, $y0);
pdf_moveto($pdf, 0, -1);
pdf_lineto($pdf, 0, -11);
pdf_moveto($pdf, 121, -1);
Beispiel #3
0
 function _cell(&$cell)
 {
     static $row_text = array();
     $row_text[] = $cell->text;
     if (!$cell->end_row) {
         return;
     }
     $this->pdf_cy = pdf_get_value($this->pdf, "texty", null);
     pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
     $height = 10;
     $txt = strip_markups($row_text[0]);
     while (pdf_show_boxed($this->pdf, $txt, 60, $this->pdf_cy, $this->pdf_x - 120, $height, 'left', 'blind')) {
         $height += 10;
     }
     if ($this->pdf_cy + $height > $this->pdf_y - 40) {
         $this->my_pdf_page_number($this->pdf, $this->pdf_x, $this->pdf_y);
         $this->my_new_pdf_end_page($this->pdf);
         $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, true);
         $this->pdf_cx = 40;
         $this->pdf_cy = 60;
     }
     pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
     if (!empty($cell->bold) && $cell->bold) {
         pdf_set_font($this->pdf, $this->pdf_font_bold, -12, 'winansi');
     } else {
         if (!empty($obj->bold) && $obj->bold) {
             pdf_set_font($this->pdf, $this->pdf_font_bold, -12, 'winansi');
         }
     }
     $off = 0;
     foreach ($row_text as $t) {
         pdf_show_boxed($this->pdf, strip_markups($t), 60 + $off, $this->pdf_cy - $height, 60 + $off + $cell->offset, $height, 'left', null);
         $off += $cell->offset;
     }
     $this->pdf_cy += $height;
     pdf_set_text_pos($this->pdf, $this->pdf_cx, $this->pdf_cy);
     pdf_continue_text($this->pdf, "");
     $row_text = array();
 }
 function end_message()
 {
     $y = pdf_get_value($this->pdf, 'texty', 0) - 10;
     pdf_moveto($this->pdf, $this->wmargin, $y);
     pdf_lineto($this->pdf, $this->pw - $this->wmargin, $y);
     pdf_moveto($this->pdf, $this->wmargin, $y - 3);
     pdf_lineto($this->pdf, $this->pw - $this->wmargin, $y - 3);
     pdf_stroke($this->pdf);
     pdf_set_text_pos($this->pdf, $this->wmargin, $y - 20);
 }