示例#1
0
function center($s, $y, $size, $fontname = "Times-Roman", $outline = 0)
{
    global $pdf, $font, $width;
    pdf_set_value($pdf, "textrendering", $outline);
    $font = pdf_findfont($pdf, $fontname, "iso8859-2");
    pdf_setfont($pdf, $font, $size);
    $w = pdf_stringwidth($pdf, $s);
    pdf_show_xy($pdf, $s, ($width - $w) / 2, $y);
}
 function findfont($name, $encoding)
 {
     // PDFLIB is limited by 'builtin' encoding for "Symbol" font
     if ($name == 'Symbol') {
         $encoding = 'builtin';
     }
     global $g_font_resolver_pdf;
     $embed = $g_font_resolver_pdf->embed[$name];
     return pdf_findfont($this->pdf, $name, $this->encoding($encoding), $embed);
 }
示例#3
0
 function PDFLib_GRenderer($format = null, $orientation = 'landscape')
 {
     // Null size does not create a graphic.
     $this->styles = array();
     $this->font = null;
     if (!is_null($format)) {
         $size = $this->_getFormat($format, $orientation);
         $this->width = $size[0];
         $this->height = $size[1];
         $this->pdf = pdf_new();
         pdf_open_file($this->pdf, '');
         pdf_begin_page($this->pdf, $this->width, $this->height);
         $this->font = pdf_findfont($this->pdf, 'Helvetica', 'builtin', 0);
     }
 }
示例#4
0
 /**
  * Set the PDF font
  *
  * @access private
  */
 function _setFont()
 {
     $this->_pdfFont = false;
     if (isset($this->_font['name'])) {
         pdf_set_parameter($this->_pdf, 'FontOutline', $this->_font['name'] . '=' . $this->_font['file']);
         $this->_pdfFont = pdf_findfont($this->_pdf, $this->_font['name'], $this->_font['encoding'], 1);
         if ($this->_pdfFont) {
             pdf_setfont($this->_pdf, $this->_pdfFont, $this->_font['size']);
             $this->_setFillStyle($this->_font['color']);
         }
     } else {
         $this->_setFillStyle('black');
     }
 }
示例#5
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>";
?>
    
示例#6
0
 function _link(&$link)
 {
     if (empty($link->text)) {
         $link->text = preg_replace('/:-:(.*?):-:/e', '$this->pres->\\1', $link->href);
     }
     if (!empty($link->leader)) {
         $leader = preg_replace('/:-:(.*?):-:/e', '$this->pres->\\1', $link->leader);
     } else {
         $leader = '';
     }
     if (!empty($link->text)) {
         $this->pdf_cy = pdf_get_value($this->pdf, "texty", null) + 10;
         pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
         $fnt = pdf_findfont($this->pdf, $this->pdf_font, 'winansi', 0);
         if (strlen($leader)) {
             $lx = pdf_stringwidth($this->pdf, $leader, $fnt, -12);
         } else {
             $lx = 0;
         }
         $dx = pdf_stringwidth($this->pdf, $link->text, $fnt, -12);
         $cw = pdf_stringwidth($this->pdf, 'm', $fnt, -12);
         // em unit width
         switch ($link->align) {
             case 'center':
                 $x = (int) ($this->pdf_x / 2 - $dx / 2 - $lx / 2);
                 break;
             case 'right':
                 $x = $this->pdf_x - $this->pdf_cx - $dx - $lx - 15;
                 break;
             case 'left':
             default:
                 $x = $this->pdf_cx;
                 break;
         }
         if ($link->marginleft) {
             $x += (int) ((double) $link->marginleft * $cw);
         }
         pdf_add_weblink($this->pdf, $x + $lx, $this->pdf_y - $this->pdf_cy - 3, $x + $dx + $lx, $this->pdf_y - $this->pdf_cy + 12, $link->text);
         pdf_show_xy($this->pdf, strip_markups($leader) . strip_markups($link->text), $x, $this->pdf_cy);
         pdf_continue_text($this->pdf, "");
     }
 }
示例#7
0
 pdf_lineto($pdf, -1, 0);
 pdf_moveto($pdf, -11, 118);
 pdf_lineto($pdf, -1, 118);
 pdf_moveto($pdf, 152, 0);
 pdf_lineto($pdf, 162, 0);
 pdf_moveto($pdf, 152, 118);
 pdf_lineto($pdf, 162, 118);
 pdf_stroke($pdf);
 $temp = '';
 // Now let's get the tracks for this album
 $tracks = $node->getSubNodes("tracks", -1);
 foreach ($tracks as $track) {
     $meta = $track->getMeta();
     $temp .= "         " . $meta['number'] . " - " . $track->getName() . "\n";
 }
 $font = pdf_findfont($pdf, 'Helvetica', 'winansi', 0);
 pdf_setfont($pdf, $font, 3);
 pdf_show_boxed($pdf, $temp, 6.5, 0, 138, 108, 'left', '');
 pdf_setfont($pdf, $font, 4);
 pdf_set_text_pos($pdf, 2, -4.5);
 //y,-x
 pdf_rotate($pdf, 90);
 pdf_show($pdf, $artist . ' - ' . $album);
 pdf_rotate($pdf, -90);
 pdf_setfont($pdf, $font, 4);
 pdf_set_text_pos($pdf, -116, 151 - 4.5);
 //-y,x
 pdf_rotate($pdf, -90);
 pdf_show($pdf, $artist . ' - ' . $album);
 pdf_rotate($pdf, 90);
 //  +---------------------------------------------------------------------------+
示例#8
0
<?php

// create handle for new PDF document
$pdf = pdf_new();
// open a file
pdf_open_file($pdf, "philosophy.pdf");
// start a new page (A4)
pdf_begin_page($pdf, 595, 842);
// get and use a font object
$arial = pdf_findfont($pdf, "Arial", "host", 1);
pdf_setfont($pdf, $arial, 10);
// print text
pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750);
pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
// end page
pdf_end_page($pdf);
// close and save file
pdf_close($pdf);
示例#9
0
<?php

define('PAGE_WIDTH', 612);
define('PAGE_HEIGHT', 792);
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_begin_page($pdf, PAGE_WIDTH, PAGE_HEIGHT);
$font = pdf_findfont($pdf, "Helvetica", "auto", false);
pdf_setfont($pdf, $font, 30);
pdf_show_xy($pdf, "PHP Developer's Handbook", 10, PAGE_HEIGHT - 40);
pdf_setfont($pdf, $font, 12);
pdf_show_xy($pdf, "Hello, World! Using PDFLib and PHP", 10, PAGE_HEIGHT - 55);
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header("Content-disposition: inline; filename=output.pdf");
header("Content-length: " . strlen($data));
echo $data;
示例#10
0
 function fud_pdf($author, $title, $subject, $page_type = 'letter', $hmargin = 15, $wmargin = 15)
 {
     $this->pdf = pdf_new();
     pdf_open_file($this->pdf, '');
     pdf_set_info($this->pdf, 'Author', $author);
     pdf_set_info($this->pdf, 'Title', $title);
     pdf_set_info($this->pdf, 'Creator', $author);
     pdf_set_info($this->pdf, 'Subject', $subject);
     pdf_set_value($this->pdf, 'compress', 9);
     switch ($page_type) {
         case 'A0':
             $this->pw = 2380;
             $this->ph = 3368;
             break;
         case 'A1':
             $this->pw = 1684;
             $this->ph = 2380;
             break;
         case 'A2':
             $this->pw = 1190;
             $this->ph = 1684;
             break;
         case 'A3':
             $this->pw = 842;
             $this->ph = 1190;
             break;
         case 'A4':
             $this->pw = 595;
             $this->ph = 842;
             break;
         case 'A5':
             $this->pw = 421;
             $this->ph = 595;
             break;
         case 'A6':
             $this->pw = 297;
             $this->ph = 421;
             break;
         case 'B5':
             $this->pw = 501;
             $this->ph = 709;
             break;
         case 'letter':
         default:
             $this->pw = 612;
             $this->ph = 792;
             break;
         case 'legal':
             $this->pw = 612;
             $this->ph = 1008;
             break;
         case 'ledger':
             $this->pw = 1224;
             $this->ph = 792;
             break;
     }
     $this->hmargin = $hmargin;
     $this->wmargin = $wmargin;
     $fonts = array('Courier', 'Courier-Bold', 'Helvetica-Bold', 'Helvetica');
     foreach ($fonts as $f) {
         $this->fonts[$f] = pdf_findfont($this->pdf, $f, 'host', false);
     }
 }
 // add heading
 $font = pdf_findfont($pdf, $fontname, 'host', 0);
 if ($font) {
     pdf_setfont($pdf, $font, 48);
 }
 $startx = ($width - pdf_stringwidth($pdf, 'PHP Certification', $font, '12')) / 2;
 pdf_show_xy($pdf, 'PHP Certification', $startx, 490);
 // add text
 $font = pdf_findfont($pdf, $fontname, 'host', 0);
 if ($font) {
     pdf_setfont($pdf, $font, 26);
 }
 $startx = 70;
 pdf_show_xy($pdf, 'This is to certify that:', $startx, 430);
 pdf_show_xy($pdf, strtoupper($name), $startx + 90, 391);
 $font = pdf_findfont($pdf, $fontname, 'host', 0);
 if ($font) {
     pdf_setfont($pdf, $font, 20);
 }
 pdf_show_xy($pdf, 'has demonstrated that they are certifiable ' . 'by passing a rigorous exam', $startx, 340);
 pdf_show_xy($pdf, 'consisting of three multiple choice questions.', $startx, 310);
 pdf_show_xy($pdf, "{$name} obtained a score of {$score}" . '%.', $startx, 260);
 pdf_show_xy($pdf, 'The test was set and overseen by the ', $startx, 210);
 pdf_show_xy($pdf, 'Fictional Institute of PHP Certification', $startx, 180);
 pdf_show_xy($pdf, "on {$date}.", $startx, 150);
 pdf_show_xy($pdf, 'Authorised by:', $startx, 100);
 // add bitmap signature image
 $signature = pdf_load_image($pdf, 'png', '/Program Files/Apache Software Foundation/Apache2.2/htdocs/phpmysql4e/chapter33/signature.png', '');
 pdf_fit_image($pdf, $signature, 200, 75, '');
 pdf_close_image($pdf, $signature);
 // set up colors for ribbon
示例#12
0
$svr = $_SERVER["PATH_TRANSLATED"];
$path_parts = pathinfo($svr);
$str_current_path = $path_parts["dirname"];
$i_top = 750;
$i_left = 50;
$i_offset = 200;
$str_pdf_name = "invoice.pdf";
$pdf = pdf_new();
pdf_open_file($pdf, "{$str_current_path}/Temp_doc/{$str_pdf_name}");
pdf_set_info($pdf, "Author", "etelegate");
pdf_set_info($pdf, "Title", "Invoice Form");
pdf_set_info($pdf, "Creator", "etelegate");
pdf_set_info($pdf, "Subject", "Invoice");
pdf_begin_page($pdf, 595, 842);
//pdf_add_outline($pdf, "Page 5");
$font = pdf_findfont($pdf, "Verdana", "winansi", 1);
pdf_setfont($pdf, $font, 12);
//pdf_set_value($pdf, "textrendering", 1);
$jpeg_image = pdf_open_image_file($pdf, "jpeg", "images/logo2os.jpg");
pdf_place_image($pdf, $jpeg_image, 200, $i_top, 1.0);
pdf_close_image($pdf, $jpeg_image);
/*$jpeg_image = pdf_open_image_file($pdf, "jpeg", "images/top1.jpg");
pdf_place_image($pdf, $jpeg_image, 300, $i_top+20, 0.5);
pdf_close_image($pdf, $jpeg_image);
$jpeg_image = pdf_open_image_file($pdf, "jpeg", "images/top4.jpg");
pdf_place_image($pdf, $jpeg_image, 301, $i_top-10, 0.5);
pdf_close_image($pdf, $jpeg_image);*/
$i_top -= 50;
pdf_show_xy($pdf, "Company Name", $i_left, $i_top);
pdf_show_xy($pdf, "[Company Name]", $i_left + $i_offset, $i_top);
$i_top -= 30;
//Create & Open PDF-Object
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author", "Bob Nijman");
pdf_set_info($pdf, "Title", "www.nijman.de");
pdf_set_info($pdf, "Creator", "*****@*****.**");
pdf_set_info($pdf, "Subject", "pdf-stuff");
###########################################
# CREATE A SEPARATE PAGE FOR EACH STUDENT #
###########################################
$query = mysql_query("SELECT studentid, fname, mi, lname FROM students ORDER BY UPPER(lname)");
while ($student = mysql_fetch_row($query)) {
    pdf_begin_page($pdf, 595, 842);
    $TimesHeader = pdf_findfont($pdf, "Times-Bold", "host");
    $body = pdf_findfont($pdf, "Helvetica", "host");
    $bodybold = pdf_findfont($pdf, "Helvetica-Bold", "host");
    // Outline rectangle
    pdf_setlinewidth($pdf, 0.5);
    //make the border of the rectangle a bit wider
    pdf_rect($pdf, 50, 200, 495, 500);
    //draw the rectangle
    pdf_stroke($pdf);
    //stroke the path with the current color(not yet :-)) and line width
    ##############
    #  TOP TEXT  #
    ##############
    // Title //
    pdf_setfont($pdf, $TimesHeader, 30);
    pdf_show_xy($pdf, "Ray High School", 50, 760);
    // Student's Name //
    pdf_setfont($pdf, $body, 12);