Example #1
1
<?php

$p = PDF_new();
/*  open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
    die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "Rainer Schaaf");
PDF_set_info($p, "Title", "Hello world (PHP)!");
PDF_begin_page_ext($p, 595, 842, "");
$font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");
PDF_setfont($p, $font, 24.0);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_continue_text($p, "(says PHP)");
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
PDF_delete($p);
Example #2
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_begin_page($p, 595, 842);
$im = pdf_open_jpeg($p, "php-big.jpg");
pdf_place_image($p, $im, 200, 700, 1.0);
pdf_place_image($p, $im, 200, 600, 0.75);
pdf_place_image($p, $im, 200, 535, 0.5);
pdf_place_image($p, $im, 200, 501, 0.25);
pdf_place_image($p, $im, 200, 486, 0.1);
$x = pdf_get_value($p, "imagewidth", $im);
$y = pdf_get_value($p, "imageheight", $im);
pdf_close_image($p, $im);
$font = PDF_findfont($p, "Times-Bold", "host", 0);
PDF_setfont($p, $font, 28.0);
pdf_show_xy($p, "{$x} by {$y}", 25, 800);
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
Header("Content-type:application/pdf");
Header("Content-Length:{$len}");
Header("Content-Disposition:inline; filename=coords.pdf");
echo $buf;
PDF_delete($p);
<?php

session_start();
//create handle for new PDF document
$pdf = PDF_new();
//open a file pdf_open_file
PDF_open_file($pdf, "");
//start a new page
PDF_begin_page($pdf, 595, 842);
//get and use a font object
$font = PDF_findfont($pdf, "Times-Roman", "host", 0);
PDF_setfont($pdf, $font, 12);
/*print text*/
// PULLING OF DATA AND OTHER PRINTING INFORMATION------------------------
if ($_SESSION['role'] == 'admin' || $_COOKIE['role'] == 'admin') {
    include 'dbFunctions.php';
    $expenditure_id = $_GET['expenditure_id'];
    $query = "SELECT * FROM expenditure WHERE expenditure_id = {$expenditure_id}";
    $runquery = mysqli_query($connect, $query);
    while ($runrows = mysqli_fetch_array($runquery)) {
        $debit_card = $runrows['debit_card'];
        $amex_card = $runrows['amex_card'];
        $visa_card = $runrows['visa_card'];
        $total_staff_salary = $runrows['total_staff_salary'];
        $phone_bill = $runrows['phone_bill'];
        $rent_bill = $runrows['rent_bill'];
        $electricity_bill = $runrows['electricity_bill'];
        $director_fee = $runrows['director_fee'];
        $date = $runrows['date'];
        $desc = $runrows['desc'];
        $total_amount = $runrows['total_amount'];
Example #4
0
    $font = PDF_load_font($p, "Helvetica", "winansi", "");
    PDF_setfont($p, $font, FONTSIZE);
    $buf = sprintf("%s (%s) %sembedded", $fontname, $encodings[$page], $embed ? "" : "not ");
    PDF_show_xy($p, $buf, LEFT - XINCR, TOP + 3 * YINCR);
    PDF_add_bookmark($p, $buf, 0, 0);
    /* print the row and column captions */
    PDF_setfont($p, $font, 2 * FONTSIZE / 3);
    for ($row = 0; $row < 16; $row++) {
        $buf = sprintf("x%X", $row);
        PDF_show_xy($p, $buf, LEFT + $row * XINCR, TOP + YINCR);
        $buf = sprintf("%Xx", $row);
        PDF_show_xy($p, $buf, LEFT - XINCR, TOP - $row * YINCR);
    }
    /* print the character table */
    $font = PDF_load_font($p, $fontname, $encodings[$page], $embed ? "embedding" : "");
    PDF_setfont($p, $font, FONTSIZE);
    $y = TOP;
    $x = LEFT;
    for ($row = 0; $row < 16; $row++) {
        for ($col = 0; $col < 16; $col++) {
            $buf = sprintf("%c", 16 * $row + $col);
            PDF_show_xy($p, $buf, $x, $y);
            $x += XINCR;
        }
        $x = LEFT;
        $y -= YINCR;
    }
    PDF_end_page($p);
    /* close page */
}
PDF_close($p);
Example #5
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 #6
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_begin_page($p, 595, 842);
$im = pdf_open_png($p, "fr-flag.png");
pdf_add_thumbnail($p, $im);
pdf_close_image($p, $im);
$top = PDF_add_bookmark($p, "Countries");
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, 20);
PDF_add_bookmark($p, "France", $top);
PDF_show_xy($p, "This is a page about France", 50, 800);
PDF_end_page($p);
PDF_begin_page($p, 595, 842);
$im = pdf_open_png($p, "dk-flag.png");
pdf_add_thumbnail($p, $im);
pdf_close_image($p, $im);
PDF_setfont($p, $font, 20);
PDF_add_bookmark($p, "Denmark", $top);
PDF_show_xy($p, "This is a page about Denmark", 50, 800);
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
Header("Content-type:application/pdf");
Header("Content-Length:{$len}");
Header("Content-Disposition:inline; filename=gra2.pdf");
echo $buf;
PDF_delete($p);
<?php

$p = PDF_new();
PDF_open_file($p);
$im = pdf_open_jpeg($p, "php-big.jpg");
$template = pdf_begin_template($p, 595, 842);
pdf_save($p);
pdf_place_image($p, $im, 4, 803, 0.25);
pdf_place_image($p, $im, 525, 803, 0.25);
pdf_moveto($p, 0, 795);
pdf_lineto($p, 595, 795);
pdf_stroke($p);
$font = PDF_findfont($p, "Times-Bold", "host", 0);
PDF_setfont($p, $font, 38.0);
pdf_show_xy($p, "PDF Template Example", 100, 807);
pdf_restore($p);
pdf_end_template($p);
pdf_close_image($p, $im);
PDF_begin_page($p, 595, 842);
pdf_place_image($p, $template, 0, 0, 1.0);
PDF_end_page($p);
PDF_begin_page($p, 595, 842);
pdf_place_image($p, $template, 0, 0, 1.0);
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
Header("Content-type:application/pdf");
Header("Content-Length:{$len}");
Header("Content-Disposition:inline; filename=gra2.pdf");
echo $buf;
Example #8
0
PDF_set_parameter($p, "hypertextencoding", "winansi");
PDF_set_info($p, "Creator", "quickreference.php");
PDF_set_info($p, "Author", "Thomas Merz");
PDF_set_info($p, "Title", "mini imposition demo (php)");
$manual = PDF_open_pdi($p, $infile, "", 0);
if (!$manual) {
    die("Error: " . PDF_get_errmsg($p));
}
$row = 0;
$col = 0;
PDF_set_parameter($p, "topdown", "true");
for ($pageno = $startpage; $pageno <= $endpage; $pageno++) {
    if ($row == 0 && $col == 0) {
        PDF_begin_page($p, $width, $height);
        $font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");
        PDF_setfont($p, $font, 18);
        PDF_set_text_pos($p, 24, 24);
        PDF_show($p, "PDFlib Quick Reference");
    }
    $page = PDF_open_pdi_page($p, $manual, $pageno, "");
    if (!$page) {
        die("Error: " . PDF_get_errmsg($p));
    }
    $optlist = sprintf("scale %f", 1 / $maxrow);
    PDF_fit_pdi_page($p, $page, $width / $maxcol * $col, ($row + 1) * $height / $maxrow, $optlist);
    PDF_close_pdi_page($p, $page);
    $col++;
    if ($col == $maxcol) {
        $col = 0;
        $row++;
    }
 /**
  * Outputs the the via PDF_show_boxed()
  *
  * Outputs the text via PDF_show_boxed() at the
  * specified coordinates, alignment and leading.
  *
  * @param    float   $xpos        The left starting position
  * @param    float   $ypos        The top starting position
  * @param    string  $alignment   "left"/"right"/"center"
  * @param    float   $leading     The text leading
  *
  * @access   public
  */
 function puttext2($xpos, $ypos, $alignment, $leading)
 {
     if (!$this->layoutvalid) {
         $this->getrequiredlinenum();
     }
     $alignment = strtolower($alignment);
     if ($leading == 0) {
         $leading = $this->fontsize;
     }
     $linenum = sizeof($this->lines);
     $height = $linenum * $leading;
     $font = PDF_findfont($this->pdf, $this->fontface, 'host', 0);
     $descender = -PDF_get_value($this->pdf, "descender", $font) * $this->fontsize;
     //PDF_setcolor($this->pdf, "both", "rgb", 0, 0, 1, 0);
     // The passed x/y-coordinates specify the top left corner of the
     // text area whereas PDF_show_boxed() interpretes the coordinates
     // as the x/y-coordinates of the bottom left corner
     $ypos -= $linenum * $leading;
     // PDF_show_boxed() interpretes the coordinates as the text
     // baseline, but we use it for specifying the geometry of the
     // complete  textblock
     $ypos += $descender;
     // PDF_show_boxed() moves the first text line down by "leading"
     // pixels; we want the first line to really appear at the top of
     // the text block
     $ypos += $leading - $this->fontsize;
     // In order to allow output via PDF_show_boxed(),
     // lines consisting only of single word (i.e. lines
     // not containing a space), are supplemented by a LF
     // character
     for ($i = 0; $i < sizeof($this->lines); $i++) {
         $line =& $this->lines[$i];
         if (strpos($line, " ") === false) {
             $line .= "\n";
         }
     }
     $text = implode(" ", $this->lines);
     $text = ereg_replace("\n +", "\n", $text);
     PDF_setfont($this->pdf, $font, $this->fontsize);
     $this->setcolor($this->fontcolor);
     PDF_set_value($this->pdf, "leading", $leading);
     PDF_show_boxed($this->pdf, $text, $xpos, $ypos - 1, $this->width, (int) ($linenum * $leading) + 1, $alignment, "");
     $this->buffer = "";
 }
Example #10
0
 function SetFont($fonte, $tamanho)
 {
     $f_user = '';
     switch ($fonte) {
         case 'normal':
             $f_user = '******';
             break;
         case 'courier':
             $f_user = '******';
             break;
         case 'courierItalico':
             $f_user = '******';
             break;
         case 'normalItalico':
             $f_user = '******';
             break;
         case 'times':
             $f_user = '******';
             break;
         case 'timesItalico':
             $f_user = '******';
             break;
         case 'symbol':
             $f_user = '******';
             break;
         case 'monospaced':
             $f_user = '******';
             break;
         default:
             $f_user = '******';
     }
     $font = PDF_findfont($this->pdf, $f_user, 'host', 0);
     PDF_setfont($this->pdf, $font, $tamanho);
     if ($this->depurar) {
         echo "<b>PDF:</b> Fonte atual de uso: " . $f_user . "<br>";
     }
 }
Example #11
0
    foreach ($row as $item) {
        echo $item;
        $u[$cnt] = $item;
        $cnt++;
    }
}
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_set_info($mypdf, "Creator", "Online Bus Service");
PDF_set_info($mypdf, "Author", "Mukesh Kumar");
PDF_set_info($mypdf, "Title", "Speedticket");
PDF_set_info($mypdf, "Subject", "Ticket");
PDF_set_info($mypdf, "Keywords", "Bus Ticket");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 12);
PDF_setcolor($mypdf, "stroke", "rgb", 0.5, 0.5, 0.5, 1);
PDF_moveto($mypdf, 50, 810);
PDF_lineto($mypdf, 500, 810);
PDF_stroke($mypdf);
PDF_moveto($mypdf, 50, 100);
PDF_lineto($mypdf, 500, 100);
PDF_stroke($mypdf);
PDF_show_xy($mypdf, "Online Bus Ticket", 200, 800);
PDF_show_xy($mypdf, "Your Ticket Details", 70, 700);
PDF_continue_text($mypdf, "Bus Details");
PDF_continue_text($mypdf, "Bus ID: " . $b[0] . " Bus Name:" . $b[1] . " From: " . $b[2] . " To: " . $b[3]);
PDF_continue_text($mypdf, "Departure: " . $b[4] . " Arrival:" . $b[5] . " Type: " . $b[6] . "Seats:" . $b[7]);
PDF_continue_text($mypdf, " Fare: " . $b[8] . " Facilities: " . $b[9] . " Stars: " . $b[10]);
PDF_continue_text($mypdf, "===================================================================");
PDF_continue_text($mypdf, "Your Details");
Example #12
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "Rasmus Lerdorf");
PDF_set_info($p, "Title", "Hello world (PHP)");
pdf_set_parameter($p, "resourcefile", "/usr/share/fonts/pdflib/pdflib.upr");
PDF_begin_page($p, 595, 842);
PDF_set_text_pos($p, 25, 800);
$fonts = array('Courier' => 0, 'Courier-Bold' => 0, 'Courier-BoldOblique' => 0, 'Courier-Oblique' => 0, 'Helvetica' => 0, 'Helvetica-Bold' => 0, 'Helvetica-BoldOblique' => 0, 'Helvetica-Oblique' => 0, 'Times-Bold' => 0, 'Times-BoldItalic' => 0, 'Times-Italic' => 0, 'Times-Roman' => 0, 'LuciduxSans' => 1, 'Utopia-Regular' => 1, 'URWGothicL-BookObli' => 1, 'URWPalladioL-Roma' => 1, 'NimbusMonL-ReguObli' => 1, 'CANDY' => 1, 'Arial' => 1);
foreach ($fonts as $f => $embed) {
    $font = PDF_findfont($p, $f, "host", $embed);
    PDF_setfont($p, $font, 25.0);
    PDF_continue_text($p, "{$f} (" . chr(128) . " Ç à á â ã ç è é ê)");
}
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
Header("Content-type:application/pdf");
Header("Content-Length:{$len}");
Header("Content-Disposition:inline; filename=hello_php.pdf");
echo $buf;
PDF_delete($p);
<?php

$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 10);
PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 500);
PDF_end_page($mypdf);
PDF_close($mypdf);
$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: {$mylen}");
header("Content-Disposition: inline; filename=gen01.pdf");
print $mybuf;
PDF_save($mypdf);
Example #14
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "Rasmus Lerdorf");
PDF_set_info($p, "Title", "Hello world (PHP)");
PDF_begin_page($p, 595, 842);
PDF_set_parameter($p, "FontOutline", "CANDY==/usr/share/fonts/truetype/CANDY.ttf");
$font = PDF_findfont($p, "CANDY", "host", 1);
PDF_setfont($p, $font, 78.0);
PDF_set_value($p, "textrendering", 2);
PDF_setcolor($p, "fill", "rgb", 0.8, 0.8, 0);
PDF_setcolor($p, "stroke", "rgb", 0, 0, 0.5);
PDF_set_text_pos($p, 20, 780);
PDF_continue_text($p, "� � � � � � � � �");
PDF_continue_text($p, "This is a test");
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
Header("Content-type:application/pdf");
Header("Content-Length:{$len}");
Header("Content-Disposition:inline; filename=candy.pdf");
echo $buf;
PDF_delete($p);