예제 #1
1
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_set_info($p, "Creator", "coords.php");
PDF_set_info($p, "Author", "Rasmus Lerdorf");
PDF_set_info($p, "Title", "Coordinate Test (PHP)");
PDF_begin_page($p, 595, 842);
PDF_translate($p, 0, 842);
// Move Origin
PDF_scale($p, 1, -1);
// Reflect across horizontal axis
PDF_set_value($p, "horizscaling", -100);
// Mirror
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, -38.0);
PDF_show_xy($p, "Top Left", 10, 40);
PDF_end_page($p);
PDF_set_parameter($p, "openaction", "fitpage");
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);
PDF_show_xy($pdf, $line, 20, $y - 300);
PDF_show_xy($pdf, $total, 250, $y - 320);
PDF_show_xy($pdf, $doubleline, 250, $y - 330);
PDF_show_xy($pdf, $descript, 30, $y - 400);
//PRINT AMOUNT ----------------------------------------------------------
$amt_x = 470;
$amt_y = 655;
PDF_show_xy($pdf, '$ ' . $debit_card, $amt_x, $amt_y - 30);
PDF_show_xy($pdf, '$ ' . $amex_card, $amt_x, $amt_y - 60);
PDF_show_xy($pdf, '$ ' . $visa_card, $amt_x, $amt_y - 90);
PDF_show_xy($pdf, '$ ' . $total_staff_salary, $amt_x, $amt_y - 120);
PDF_show_xy($pdf, '$ ' . $phone_bill, $amt_x, $amt_y - 150);
PDF_show_xy($pdf, '$ ' . $rent_bill, $amt_x, $amt_y - 180);
PDF_show_xy($pdf, '$ ' . $electricity_bill, $amt_x, $amt_y - 210);
PDF_show_xy($pdf, '$ ' . $director_fee, $amt_x, $amt_y - 240);
PDF_show_xy($pdf, '$ ' . $consignment_payment, $amt_x, $amt_y - 270);
PDF_show_xy($pdf, '$ ' . $total_amount, $amt_x, $amt_y - 320);
PDF_show_xy($pdf, strtoupper($desc), 150, $amt_y - 400);
PDF_close_image($pdf, $images);
//test
/*end page*/
PDF_end_page($pdf);
/*close and save file*/
PDF_close($pdf);
$buf = PDF_get_buffer($pdf);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
header("Content-Disposition: inline; filename=gen01.pdf");
print $buf;
PDF_save($pdf);
예제 #3
0
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
header("Content-type: application/pdf");
header("Content-length: {$pdflen}");
header("Content-Disposition: inline; filename=phpMade.pdf");
//output the document
print $pdf;
//delete the object
PDF_delete($pdfFile);
예제 #4
0
파일: chartab.php 프로젝트: kodybrown/haiku
    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);
/* close PDF document	*/
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
header("Content-Disposition: inline; filename=hello.pdf");
예제 #5
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_begin_page($p, 595, 842);
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, 38.0);
PDF_set_parameter($p, "overline", "true");
PDF_show_xy($p, "Overlined Text", 50, 780);
PDF_set_parameter($p, "overline", "false");
PDF_set_parameter($p, "underline", "true");
PDF_continue_text($p, "Underlined Text");
PDF_set_parameter($p, "strikeout", "true");
PDF_continue_text($p, "Underlined strikeout Text");
PDF_set_parameter($p, "underline", "false");
PDF_set_parameter($p, "strikeout", "false");
PDF_setcolor($p, "fill", "rgb", 1.0, 0.1, 0.1);
PDF_continue_text($p, "Red Text");
PDF_setcolor($p, "fill", "rgb", 0, 0, 0);
PDF_set_value($p, "textrendering", 1);
PDF_setcolor($p, "stroke", "rgb", 0, 0.5, 0);
PDF_continue_text($p, "Green Outlined Text");
PDF_set_value($p, "textrendering", 2);
PDF_setcolor($p, "fill", "rgb", 0, 0.2, 0.8);
PDF_setlinewidth($p, 2);
PDF_continue_text($p, "Green Outlined Blue Text");
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
Header("Content-type:application/pdf");
예제 #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);
 /**
  * Output the the via the integrated layout engine
  *
  * Outputs the text via the integrated layout engine 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 puttext($xpos, $ypos, $alignment, $leading)
 {
     if (!$this->layoutvalid) {
         $this->getrequiredlinenum();
     }
     $alignment = strtolower($alignment);
     if ($leading == 0) {
         $leading = $this->fontsize;
     }
     $linenum = sizeof($this->lines);
     $height = $linenum * $this->fontsize + ($linenum - 1) * ($leading - $this->fontsize);
     // DEBUG
     //PDF_setcolor($this->pdf, "both", "rgb", 1, 0, 0, 0);
     //PDF_rect($this->pdf, $xpos, $ypos-$height, $this->width, $height);
     //PDF_fill($this->pdf);
     //PDF_setcolor($this->pdf, "both", "rgb", 0, 0, 0, 0);
     $font = PDF_findfont($this->pdf, $this->fontface, 'host', 0);
     PDF_setfont($this->pdf, $font, $this->fontsize);
     PDF_set_parameter($this->pdf, "underline", "false");
     PDF_set_parameter($this->pdf, "overline", "false");
     PDF_set_parameter($this->pdf, "strikeout", "false");
     if (is_array($this->fontparset)) {
         foreach ($this->fontparset as $par) {
             PDF_set_parameter($this->pdf, $par, "true");
         }
     }
     // Decrease the vertical position of the text, as the
     // passed x/y-coordinates specify the left top corner
     // of the text whereas PDF_show_xy() uses the coordinates
     // for the text baseline
     $ascender = PDF_get_value($this->pdf, "ascender", $font) * $this->fontsize;
     $ypos -= $ascender + 1;
     $this->setcolor($this->fontcolor);
     for ($i = 0; $i < sizeof($this->lines); $i++) {
         $line =& $this->lines[$i];
         $linewidth =& $this->linewidths[$i];
         // DEBUG
         //PDF_show_xy($this->pdf, $linewidth, 0, $ypos);
         switch ($alignment) {
             default:
             case "left":
                 PDF_show_xy($this->pdf, "{$line}", $xpos, $ypos);
                 break;
             case "right":
                 PDF_show_xy($this->pdf, $line, $xpos + $this->width - $linewidth, $ypos);
                 break;
             case "center":
                 PDF_show_xy($this->pdf, $line, $xpos + ($this->width - $linewidth) / 2, $ypos);
                 break;
         }
         $ypos -= $leading;
     }
     $this->buffer = "";
 }
    PDF_show_xy($pdf, $_SESSION['suppplier_consignment_session'][$i] . '%', 190, $y);
    PDF_show_xy($pdf, $_SESSION['product_qty_session'][$i], 295, $y);
    PDF_show_xy($pdf, '$ ' . $_SESSION['sales_final_session'][$i], 355, $y);
    PDF_show_xy($pdf, '$ ' . $_SESSION['sold_final_session'][$i], 436, $y);
    PDF_show_xy($pdf, '$ ' . $_SESSION['payment_session'][$i], 516, $y);
    $y -= 20;
}
// TOTAL PAYMENT AMOUNT
$y = 660;
for ($i = 0; $i < $count_session_item; $i++) {
    $y -= 20;
}
PDF_show_xy($pdf, $line, 20, $y);
PDF_show_xy($pdf, $totalheader, 20, $y - 20);
PDF_show_xy($pdf, '$ ' . $total_sales_amt, 355, $y - 20);
PDF_show_xy($pdf, '$ ' . $total_sold_amt, 436, $y - 20);
PDF_show_xy($pdf, '$ ' . $total_consignment, 516, $y - 20);
PDF_show_xy($pdf, $doubleline, 20, $y - 30);
PDF_close_image($pdf, $images);
//test
/*end page*/
PDF_end_page($pdf);
/*close and save file*/
PDF_close($pdf);
$buf = PDF_get_buffer($pdf);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
header("Content-Disposition: inline; filename=gen01.pdf");
print $buf;
PDF_save($pdf);
예제 #9
0
 function Write($msg, $xo, $yo, $x, $y, $fonte = 'normal', $tamanho = '10', $color = '#888888', $align = 'center', $local = 'box')
 {
     $this->SetFont($fonte, $tamanho);
     $this->SetBoth($color);
     switch ($local) {
         case 'xy':
             PDF_show_xy($this->pdf, $msg, $xo, $yo);
             break;
         default:
             // 'box'
             $yo = $this->altura - $yo;
             PDF_show_boxed($this->pdf, $msg, $xo, $yo, $x, $y, $align, '');
     }
     if ($this->depurar) {
         echo "<b>PDF:</b> Adicionado o texto: <pre>{$msg}</pre><br>";
     }
 }
예제 #10
0
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");
PDF_continue_text($mypdf, "Your Name: " . $u[0] . " Email: " . $u[1] . " Mobile: " . $u[2] . " Address: " . $u[3]);
PDF_continue_text($mypdf, "Country: " . $u[4] . " Gender: " . $u[5] . " BusID: " . $u[6] . " Bus Date: " . $u[7]);
PDF_continue_text($mypdf, "Registration Date: " . $u[8] . " Your Seats: " . $u[9] . " Seats: " . $u[10]);
PDF_continue_text($mypdf, "Price: " . $u[11] . " PNR: " . $u[12]);
PDF_continue_text($mypdf, "===================================================================");
PDF_continue_text($mypdf, "IMPORTANT INFORMATION");
PDF_continue_text($mypdf, "No. of Seats: " . $u[9]);
PDF_continue_text($mypdf, " Seats: " . $u[10]);
PDF_continue_text($mypdf, "PNR: " . $u[12]);
PDF_continue_text($mypdf, "===================================================================");
PDF_continue_text($mypdf, "Contact us : 9957809805");
PDF_continue_text($mypdf, "Terms and Conditions Apply");
PDF_continue_text($mypdf, "Visit www.01fes.com");
PDF_show_xy($mypdf, "HAPPY JOURNEY", 200, 400);
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=busticket4.pdf");
print $mybuf;
PDF_delete($mypdf);
예제 #11
0
<?php

$p = PDF_new();
PDF_open_file($p);
PDF_set_info($p, "Creator", "coords.php");
PDF_set_info($p, "Author", "Rasmus Lerdorf");
PDF_set_info($p, "Title", "Coordinate Test (PHP)");
PDF_begin_page($p, 595, 842);
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, 38.0);
PDF_show_xy($p, "Bottom Left", 10, 10);
PDF_show_xy($p, "Bottom Right", 350, 10);
PDF_show_xy($p, "Top Left", 10, 802);
PDF_show_xy($p, "Top Right", 410, 802);
PDF_show_xy($p, "Center", 595 / 2 - 60, 842 / 2 - 20);
PDF_end_page($p);
PDF_set_parameter($p, "openaction", "fitpage");
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);
예제 #12
0
/* Make an instance of the class */
$barcode = new jh_pdf_barcode(&$pdf);
/* Set the type to 2 of 5 interleaved */
$barcode->settype('25i');
/* Define some test codes */
$code1 = "1231231230";
$code2 = "4564564560";
$code3 = "7897897890";
/* Define a font which will be used to put the plain text
   under the barcode fields */
$font = PDF_findfont($pdf, "Helvetica", 'host', 0);
PDF_setfont($pdf, $font, 12);
/* Set the barcode text and put it onto the PDF document */
$barcode->settext($code1);
$barcode->putcode(30, 812, 100, 50);
/* Put the textual representation under the barcode */
PDF_show_xy($pdf, $code1, 30, 750);
$barcode->settext($code2);
$barcode->putcode(230, 812, 100, 50);
PDF_show_xy($pdf, $code2, 230, 750);
$barcode->settext($code3);
$barcode->putcode(430, 812, 100, 50);
PDF_show_xy($pdf, $code3, 430, 750);
/* Close the last page */
PDF_end_page($pdf);
/* Close the PDF document */
PDF_close($pdf);
/* Output the in-memory created PDF document */
print PDF_get_buffer($pdf);
/* Delete the PDFlib object */
PDF_delete($pdf);
예제 #13
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);
$font = PDF_findfont($p, "Helvetica-Bold", "host", 0);
PDF_setfont($p, $font, 38.0);
PDF_show_xy($p, "Hello world!", 50, 700);
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);
//for loop to loop through items thru my array
$x = 510;
$y = 680;
for ($i = 0; $i < count($items); $i++) {
    PDF_show_xy($pdf, "\$" . $price[$i], $x, $y);
    $y -= 30;
}
PDF_show_xy($pdf, '$' . $total_original_price, 510, $y - 50);
PDF_show_xy($pdf, '$' . $total_discount_price, 510, $y - 80);
PDF_show_xy($pdf, $final_discount_header, 40, $y - 80);
PDF_show_xy($pdf, $line2, 322, $y - 90);
PDF_show_xy($pdf, $total, 325, $y - 110);
PDF_show_xy($pdf, $doubleline, 322, $y - 120);
PDF_show_xy($pdf, strtoupper($promo), 40, $y - 210);
PDF_show_xy($pdf, strtoupper($VIP), 40, $y - 230);
PDF_show_xy($pdf, strtoupper($ptotal), 438, $y - 140);
PDF_show_xy($pdf, $change, 425, $y - 160);
PDF_show_xy($pdf, $thankyou, 40, $y - 260);
PDF_close_image($pdf, $images);
//end page
PDF_end_page($pdf);
//close and save file
PDF_close($pdf);
//in our own memory buffer, determine the length of it, create the http headers that are required
$buf = PDF_get_buffer($pdf);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: {$len}");
header("Content-Disposition: inline; filename=receipt.pdf");
print $buf;
PDF_save($pdf);