Example #1
0
 /**
  * Create the PDF canvas.
  *
  * Parameters available:
  *
  * 'page' Specify the page/paper format for the graph's page, available
  * formats are: A0, A1, A2, A3, A4, A5, A6, B5, letter, legal, ledger,
  * 11x17, cd_front, inlay, inlay_nosides
  *
  * 'align' Alignment of the graph on the page, available options are:
  * topleft, topcenter, topright, leftcenter, center, rightcenter,
  * leftbottom, centerbottom, rightbottom
  *
  * 'orientation' Specifies the paper orientation, default is 'portrait' and
  * 'landscape' is also supported.
  *
  * 'creator' The creator tag of the PDF/graph
  *
  * 'author' The author tag of the PDF/graph
  *
  * 'title' The title tag of the PDF/graph
  *
  * 'width' The width of the graph on the page
  *
  * 'height' The height of the graph on the page
  *
  * 'left' The left offset of the graph on the page
  *
  * 'top' The top offset of the graph on the page
  *
  * 'filename' The PDF file to open/add page to, using 'filename' requires
  * the commercial version of PDFlib (http://www.pdflib.com/), this has for
  * obvious ($ 450) reasons not been tested
  *
  * 'pdf' An existing PDFlib PDF document to add the page to
  *
  * 'add_page' (true/false) Used together with 'pdf', to specify whether the
  * canvas should add a new graph page (true) or create the graph on the
  * current page (false), default is 'true'
  *
  * The 'page' and 'width' & 'height' can be mutually omitted, if 'page' is
  * omitted the page is created using dimensions of width x height, and if
  * width and height are omitted the page dimensions are used for the graph.
  *
  * If 'pdf' is specified, 'filename', 'creator', 'author' and 'title' has no
  * effect.
  *
  * 'left' and 'top' are overridden by 'align'
  *
  * It is required either to specify 'width' & 'height' or 'page'.
  *
  * The PDF format/PDFlib has some limitations on the capabilities, which
  * means some functionality available using other canvass (fx. alpha
  * blending and gradient fills) are not supported with PDF (see Canvas.txt
  * in the docs/ folder for further details)
  *
  * @param array $param Parameter array
  */
 function Image_Canvas_PDF($param)
 {
     if (isset($param['page'])) {
         switch (strtoupper($param['page'])) {
             case 'A0':
                 $this->_pageWidth = 2380;
                 $this->_pageHeight = 3368;
                 break;
             case 'A1':
                 $this->_pageWidth = 1684;
                 $this->_pageHeight = 2380;
                 break;
             case 'A2':
                 $this->_pageWidth = 1190;
                 $this->_pageHeight = 1684;
                 break;
             case 'A3':
                 $this->_pageWidth = 842;
                 $this->_pageHeight = 1190;
                 break;
             case 'A4':
                 $this->_pageWidth = 595;
                 $this->_pageHeight = 842;
                 break;
             case 'A5':
                 $this->_pageWidth = 421;
                 $this->_pageHeight = 595;
                 break;
             case 'A6':
                 $this->_pageWidth = 297;
                 $this->_pageHeight = 421;
                 break;
             case 'B5':
                 $this->_pageWidth = 501;
                 $this->_pageHeight = 709;
                 break;
             case 'LETTER':
                 $this->_pageWidth = 612;
                 $this->_pageHeight = 792;
                 break;
             case 'LEGAL':
                 $this->_pageWidth = 612;
                 $this->_pageHeight = 1008;
                 break;
             case 'LEDGER':
                 $this->_pageWidth = 1224;
                 $this->_pageHeight = 792;
                 break;
             case '11X17':
                 $this->_pageWidth = 792;
                 $this->_pageHeight = 1224;
                 break;
             case 'CD_FRONT':
                 $this->_pageWidth = 337;
                 $this->_pageHeight = 337;
                 break;
             case 'INLAY':
                 $this->_pageWidth = 425;
                 $this->_pageHeight = 332;
                 break;
             case 'INLAY_NOSIDES':
                 $this->_pageWidth = 390;
                 $this->_pageHeight = 332;
                 break;
         }
     }
     if (isset($param['orientation']) && strtoupper($param['orientation']) == 'LANDSCAPE') {
         $w = $this->_pageWidth;
         $this->_pageWidth = $this->_pageHeight;
         $this->_pageHeight = $w;
     }
     parent::Image_Canvas($param);
     if (!$this->_pageWidth) {
         $this->_pageWidth = $this->_width;
     } elseif (!$this->_width) {
         $this->_width = $this->_pageWidth;
     }
     if (!$this->_pageHeight) {
         $this->_pageHeight = $this->_height;
     } elseif (!$this->_height) {
         $this->_height = $this->_pageHeight;
     }
     $this->_width = min($this->_width, $this->_pageWidth);
     $this->_height = min($this->_height, $this->_pageHeight);
     if (isset($param['align']) && ($this->_width != $this->_pageWidth || $this->_height != $this->_pageHeight)) {
         switch (strtoupper($param['align'])) {
             case 'TOPLEFT':
                 $this->_top = 0;
                 $this->_left = 0;
                 break;
             case 'TOPCENTER':
                 $this->_top = 0;
                 $this->_left = ($this->_pageWidth - $this->_width) / 2;
                 break;
             case 'TOPRIGHT':
                 $this->_top = 0;
                 $this->_left = $this->_pageWidth - $this->_width;
                 break;
             case 'LEFTCENTER':
                 $this->_top = ($this->_pageHeight - $this->_height) / 2;
                 $this->_left = 0;
                 break;
             case 'CENTER':
                 $this->_top = ($this->_pageHeight - $this->_height) / 2;
                 $this->_left = ($this->_pageWidth - $this->_width) / 2;
                 break;
             case 'RIGHTCENTER':
                 $this->_top = ($this->_pageHeight - $this->_height) / 2;
                 $this->_left = $this->_pageWidth - $this->_width;
                 break;
             case 'LEFTBOTTOM':
                 $this->_top = $this->_pageHeight - $this->_height;
                 $this->_left = 0;
                 break;
             case 'CENTERBOTTOM':
                 $this->_top = $this->_pageHeight - $this->_height;
                 $this->_left = ($this->_pageWidth - $this->_width) / 2;
                 break;
             case 'RIGHTBOTTOM':
                 $this->_top = $this->_pageHeight - $this->_height;
                 $this->_left = $this->_pageWidth - $this->_width;
                 break;
         }
     }
     $this->_pdflib = $this->_version();
     $addPage = true;
     if (isset($param['pdf']) && is_resource($param['pdf'])) {
         $this->_pdf =& $param['pdf'];
         if (isset($param['add_page']) && $param['add_page'] === false) {
             $addPage = false;
         }
     } else {
         $this->_pdf = pdf_new();
         if (isset($param['filename'])) {
             pdf_open_file($this->_pdf, $param['filename']);
         } else {
             pdf_open_file($this->_pdf, '');
         }
         pdf_set_parameter($this->_pdf, 'warning', 'true');
         pdf_set_info($this->_pdf, 'Creator', isset($param['creator']) ? $param['creator'] : 'PEAR::Image_Canvas');
         pdf_set_info($this->_pdf, 'Author', isset($param['author']) ? $param['author'] : 'Jesper Veggerby');
         pdf_set_info($this->_pdf, 'Title', isset($param['title']) ? $param['title'] : 'Image_Canvas');
     }
     if ($addPage) {
         pdf_begin_page($this->_pdf, $this->_pageWidth, $this->_pageHeight);
     }
     $this->_reset();
 }
 function reset(&$media)
 {
     OutputDriverGenericPDF::reset($media);
     // Check if PDFLIB is available
     if (!extension_loaded('pdf')) {
         // Try to use "dl" to dynamically load PDFLIB
         $result = dl(PDFLIB_DL_PATH);
         if (!$result) {
             readfile(HTML2PS_DIR . 'templates/missing_pdflib.html');
             error_log("No PDFLIB extension found");
             die("HTML2PS Error");
         }
     }
     $this->pdf = pdf_new();
     // Set PDF compatibility level
     pdf_set_parameter($this->pdf, "compatibility", $this->get_pdf_version());
     /**
      * Use PDF license key, if present
      *
      * PDFLIB_LICENSE constant is defined in 'config.inc.php' file in "PDFLIB-specific" section.
      */
     if (defined("PDFLIB_LICENSE")) {
         pdf_set_parameter($this->pdf, "license", PDFLIB_LICENSE);
     }
     pdf_open_file($this->pdf, $this->get_filename());
     // @TODO: compression level, debug
     pdf_set_value($this->pdf, "compress", 0);
     // Set path to the PDFLIB UPR file containig information about fonts and encodings
     if (defined("PDFLIB_UPR_PATH")) {
         pdf_set_parameter($this->pdf, "resourcefile", PDFLIB_UPR_PATH);
     }
     // Setup encodings not bundled with PDFLIB
     $filename = $this->generate_cpg('koi8-r');
     pdf_set_parameter($this->pdf, 'Encoding', sprintf('koi8-r=%s', $filename));
     // Setup font outlines
     global $g_font_resolver_pdf;
     $g_font_resolver_pdf->setup_ttf_mappings($this->pdf);
     $pdf = $this->pdf;
     pdf_set_info($pdf, "Creator", "html2ps (PHP version)");
     // No borders around links in the generated PDF
     pdf_set_border_style($this->pdf, "solid", 0);
     $this->_status = PDFLIB_STATUS_DOCUMENT_STARTED;
 }
Example #3
0
$margin = 120;
$ring = 40;
$header = 20;
$footer = 228;
$file = tempnam("", "tests") . '.pdf';
$width = 2 * ($radius + $margin);
$height = 2 * ($radius + $margin) + $header + $footer;
$pdf = pdf_new();
if (!pdf_open_file($pdf, $file)) {
    echo "error";
    exit;
}
pdf_set_parameter($pdf, "warning", "true");
pdf_set_info($pdf, "Creator", "Phalanger");
pdf_set_info($pdf, "Author", "Uwe Steinmann");
pdf_set_info($pdf, "Title", "Analog Clock");
pdf_begin_page($pdf, $width, $height);
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);
}
/* outlined */
center("It is {$texttime}.", $height - 60, 42, "Times-Roman", 1);
center("It is time for", 200, 100, "Times-Roman", 1);
/* filled */
center("Phalanger!", 70, 110, "Times-Bold", 0);
Example #4
0
<?php

//getting new instance
$pdfFile = new_pdf();
PDF_open_file($pdfFile, " ");
//document info
pdf_set_info($pdfFile, "Auther", "Ahmed Elbshry");
pdf_set_info($pdfFile, "Creator", "Ahmed Elbshry");
pdf_set_info($pdfFile, "Title", "PDFlib");
pdf_set_info($pdfFile, "Subject", "Using PDFlib");
//starting our page and define the width and highet of the document
pdf_begin_page($pdfFile, 595, 842);
//check if Arial font is found, or exit
if ($font = PDF_findfont($pdfFile, "Arial", "winansi", 1)) {
    PDF_setfont($pdfFile, $font, 12);
} else {
    echo "Font Not Found!";
    PDF_end_page($pdfFile);
    PDF_close($pdfFile);
    PDF_delete($pdfFile);
    exit;
}
//start writing from the point 50,780
PDF_show_xy($pdfFile, "This Text In Arial Font", 50, 780);
PDF_end_page($pdfFile);
PDF_close($pdfFile);
//store the pdf document in $pdf
$pdf = PDF_get_buffer($pdfFile);
//get  the len to tell the browser about it
$pdflen = strlen($pdfFile);
//telling the browser about the pdf document
Example #5
0
 function _presentation(&$presentation)
 {
     global $pres;
     $_SESSION['selected_display_mode'] = get_class($this);
     // In PDF mode we loop through all the slides and make a single
     // big multi-page PDF document.
     $this->page_number = 0;
     $this->pdf = pdf_new();
     if (!empty($pdfResourceFile)) {
         pdf_set_parameter($this->pdf, "resourcefile", $pdfResourceFile);
     }
     pdf_open_file($this->pdf, null);
     pdf_set_info($this->pdf, "Author", isset($presentation->speaker) ? $presentation->speaker : "Anonymous");
     pdf_set_info($this->pdf, "Title", isset($presentation->title) ? $presentation->title : "No Title");
     pdf_set_info($this->pdf, "Creator", "See Author");
     pdf_set_info($this->pdf, "Subject", isset($presentation->topic) ? $presentation->topic : "");
     while (list($this->slideNum, $slide) = each($presentation->slides)) {
         // testing hack
         $slideDir = dirname($this->presentationDir . '/' . $presentation->slides[$this->slideNum]->filename) . '/';
         $fn = $this->presentationDir . '/' . $presentation->slides[$this->slideNum]->filename;
         $fh = fopen($fn, "rb");
         $r =& new XML_Slide($fh);
         $r->setErrorHandling(PEAR_ERROR_DIE, "%s ({$fn})\n");
         $r->parse();
         $this->objs = $r->getObjects();
         $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, true);
         $this->pdf_cx = $this->pdf_cy = 0;
         // Globals that keep our current x,y position
         while (list($this->coid, $obj) = each($this->objs)) {
             $obj->display();
         }
         $this->my_new_pdf_end_page($this->pdf);
     }
     $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, true);
     pdf_set_font($this->pdf, $this->pdf_font, -20, 'winansi');
     $fnt = pdf_findfont($this->pdf, $this->pdf_font, 'winansi', 0);
     $dx = pdf_stringwidth($this->pdf, "Index", $fnt, -20);
     $x = (int) ($this->pdf_x / 2 - $dx / 2);
     pdf_set_parameter($this->pdf, "underline", 'true');
     pdf_show_xy($this->pdf, "Index", $x, 60);
     pdf_set_parameter($this->pdf, "underline", 'false');
     $this->pdf_cy = pdf_get_value($this->pdf, "texty", null) + 30;
     $old_cy = $this->pdf_cy;
     pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
     if (is_array($this->page_index)) {
         foreach ($this->page_index as $pn => $ti) {
             if ($ti == 'titlepage') {
                 continue;
             }
             $ti .= '    ';
             while (pdf_stringwidth($this->pdf, $ti, $fnt, -12) < $this->pdf_x - $this->pdf_cx * 2.5 - 140) {
                 $ti .= '.';
             }
             pdf_show_xy($this->pdf, $ti, $this->pdf_cx * 2.5, $this->pdf_cy);
             $dx = pdf_stringwidth($this->pdf, $pn, $fnt, -12);
             pdf_show_xy($this->pdf, $pn, $this->pdf_x - 2.5 * $this->pdf_cx - $dx, $this->pdf_cy);
             $this->pdf_cy += 15;
             if ($this->pdf_cy > $this->pdf_y - 50) {
                 $this->my_new_pdf_end_page($this->pdf);
                 $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, false);
                 $this->pdf_cy = $old_cy;
                 pdf_set_font($this->pdf, $this->pdf_font, -12, 'winansi');
             }
         }
     }
     $this->my_new_pdf_end_page($this->pdf);
     pdf_close($this->pdf);
     $data = pdf_get_buffer($this->pdf);
     header('Content-type: application/pdf');
     header('Content-disposition: inline; filename=' . $_SESSION['currentPres'] . '.pdf');
     header("Content-length: " . strlen($data));
     echo $data;
 }
Example #6
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>";
?>
    
Example #7
0
<?php

if (!extension_loaded('pdf')) {
    echo 'Este servidor no puede generar PDFs, ';
    echo 'pero puedes bajar <a href="invoice.pdf">la factura</a> ';
    echo 'previamente generada por este programa';
    exit;
}
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author", "Jes&#250;s M. Castagnetto");
pdf_set_info($pdf, "Title", "Ejemplo de Factura");
pdf_set_info($pdf, "Creator", "Jes&#250;s M. Castagnetto");
pdf_set_info($pdf, "Subject", "Ejemplo de Factura");
$sizes = array('a4' => '595x842', 'letter' => '612x792', 'legal' => '612x1008');
if (!isset($type)) {
    $type = 'a4';
}
list($x, $y) = explode('x', $sizes[$type]);
$items = array(array('Un programa simple que hace de todo', '299.99'), array('El programa especial sin el que el anterior no corre', '1899'), array('Una libreria de comunicacion', '29.95'), array('Un programa para bloquear la comunicacion', '49.95'), array('Una libreria que comprime todo a 1 byte', '49.9'), array('Y un programa que permite recuperar lo comprimido a 1 byte', '39999.95'));
pdf_begin_page($pdf, $x, $y);
$imagepath = realpath('../images/booger.jpg');
$im = pdf_open_jpeg($pdf, $imagepath);
pdf_place_image($pdf, $im, 5, $y - 72, 0.5);
pdf_close_image($pdf, $im);
pdf_set_value($pdf, 'textrendering', 0);
// fill
pdf_set_font($pdf, "Helvetica", 12, winansi);
pdf_show_xy($pdf, 'Micro Snot & L4m3r5 S.R.L.', 145, $y - 20);
pdf_continue_text($pdf, '123 Calle del Dolor');
pdf_continue_text($pdf, 'Tacora, Lima 666');
Example #8
0
//  +------------------------------------------------------------------------+
//  | Initialize PDF                                                         |
//  +------------------------------------------------------------------------+
$pdf = pdf_new();
if (pdf_get_value($pdf, 'major', 0) < 5) {
    pdf_close($pdf);
    message(__FILE__, __LINE__, 'error', '[b]netjukebox requires PDFlib 5 or later[/b]');
}
pdf_open_file($pdf, '');
$font = pdf_load_font($pdf, 'Helvetica', 'host', '');
// winansi, host, iso8859-1, unicode >> unicode and glyph id addressing not supported in PDFlib Lite!!!
if (NJB_DEFAULT_CHARSET == 'UTF-8') {
    pdf_set_parameter($pdf, 'textformat', 'utf8');
}
pdf_set_info($pdf, 'Creator', 'netjukebox ' . NJB_VERSION);
pdf_set_info($pdf, 'Title', $album['artist'] . ' - ' . $album['album']);
$width = 210;
// A4
$height = 297;
// A4
$scale = 72 / 25.4;
// mm to dtp-point (1 point = 1/72 inch; 1 inch = 25.4 mm)
$hash_data = pdf_get_value($pdf, 'major', 0) . '-' . pdf_get_value($pdf, 'minor', 0) . '-' . NJB_VERSION;
$hash_data .= '-' . $album['artist'] . ' - ' . $album['album'] . '-' . $width . '-' . $height;
pdf_begin_page($pdf, $width * $scale, $height * $scale);
pdf_scale($pdf, $scale, $scale);
pdf_setlinewidth($pdf, 0.1);
//  +------------------------------------------------------------------------+
//  | PDF back cover                                                         |
//  +------------------------------------------------------------------------+
$x0 = 30;
Example #9
0
* @version 6/20/05
* @param $node The node that we are viewing
**/
global $config_version, $node;
// Did they want to create it?
if (isset($_GET['sub_action'])) {
    if ($_GET['sub_action'] == "create") {
        // Ok, let's create the PDF
        // Code borrowed from Netjukebox - www.netjukebox.nl
        $album = $node->getName();
        $artnode = $node->getAncestor("artist");
        $artist = $artnode->getName();
        $pdf = pdf_new();
        pdf_open_file($pdf, '');
        pdf_set_info($pdf, 'Title', $artist . " - " . $album);
        pdf_set_info($pdf, 'Creator', 'Jinzora ' . $config_version);
        pdf_begin_page($pdf, 595, 842);
        //A4
        $scale = 2.834645676;
        //mm to dtp-point (1 point = 1/72 inch)
        pdf_scale($pdf, $scale, $scale);
        pdf_setlinewidth($pdf, 0.1);
        //  +---------------------------------------------------------------------------+
        //  | PDF Back Cover                                                            |
        //  +---------------------------------------------------------------------------+
        $x0 = 30;
        $y0 = 22;
        pdf_translate($pdf, $x0, $y0);
        pdf_moveto($pdf, 0, -1);
        pdf_lineto($pdf, 0, -11);
        pdf_moveto($pdf, 6.5, -1);
Example #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);
     }
 }
Example #11
0
<?php

$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);
Example #12
0
<?php

$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author", "Rasmus Lerdorf");
pdf_set_info($pdf, "Title", "Sample Invoice");
pdf_set_info($pdf, "Creator", "See Author");
pdf_set_info($pdf, "Subject", "Sample Invoice");
$sizes = array('a4' => '595x842', 'letter' => '612x792', 'legal' => '612x1008');
if (!isset($type)) {
    $type = 'letter';
}
list($x, $y) = explode('x', $sizes[$type]);
$items = array(array('Our special low-cost widget that does everything', '299.99'), array('Our special high-cost widget that does more', '1899'), array('A blue widget', '29.95'), array('And a red widget', '49.95'), array('A yellow widget that makes noise', '49.9'), array('And one that doesn\'t', '999.95'));
pdf_begin_page($pdf, $x, $y);
$im = pdf_open_jpeg($pdf, "php-big.jpg");
pdf_place_image($pdf, $im, 5, $y - 72, 0.5);
pdf_close_image($pdf, $im);
pdf_set_value($pdf, 'textrendering', 0);
// fill
pdf_set_font($pdf, "Helvetica", 12, winansi);
pdf_show_xy($pdf, 'Generic Evil Company Inc.', 145, $y - 20);
pdf_continue_text($pdf, '123 Main Street');
pdf_continue_text($pdf, 'Dark City, CA 98765');
pdf_set_font($pdf, "Helvetica", 10, winansi);
pdf_show_xy($pdf, 'Helpless Customer Ltd.', 20, $y - 100);
pdf_continue_text($pdf, '2 Small Street');
pdf_continue_text($pdf, 'Little Town, ID 56789');
pdf_set_font($pdf, "Helvetica", 10, winansi);
pdf_show_xy($pdf, 'Terms: Net 30', 150, $y - 100);
pdf_continue_text($pdf, 'PO #:  12345');
// Get a list of semesterids for this term //
// Get a list of the semesters we'll be using //
$query = mysql_query("SELECT semesterid FROM semesters WHERE termid = {$_POST['term']} ORDER BY startdate ASC");
while ($id = mysql_fetch_row($query)) {
    $semester[] = $id[0];
}
###############
#  START PDF  #
###############
//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);