Exemple #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 _show_watermark($watermark)
 {
     $font = $this->findfont('Helvetica', 'iso-8859-1');
     pdf_setfont($this->pdf, $font, 100);
     $x = $this->left + $this->width / 2;
     $y = $this->bottom + $this->height / 2 + $this->offset;
     pdf_set_value($this->pdf, "textrendering", 1);
     pdf_translate($this->pdf, $x, $y);
     pdf_rotate($this->pdf, 60);
     pdf_show_xy($this->pdf, $watermark, -pdf_stringwidth($this->pdf, $watermark, $font, 100) / 2, -50);
 }
 function _show_watermark()
 {
     if (is_null($this->_watermark) || $this->_watermark == "") {
         return;
     }
     $font = $this->_control_font();
     pdf_setfont($this->pdf, $font, 100);
     $x = $this->left + $this->width / 2;
     $y = $this->bottom + $this->height / 2 + $this->offset;
     pdf_set_value($this->pdf, "textrendering", 1);
     pdf_translate($this->pdf, $x, $y);
     pdf_rotate($this->pdf, 60);
     pdf_show_xy($this->pdf, $this->_watermark, -pdf_stringwidth($this->pdf, $this->_watermark, $font, 100) / 2, -50);
 }
Exemple #4
0
 function my_new_pdf_page(&$pdf, $x, $y, $new_page = true)
 {
     if ($new_page) {
         $this->page_number++;
     }
     pdf_begin_page($pdf, $x, $y);
     // Having the origin in the bottom left corner confuses the
     // heck out of me, so let's move it to the top-left.
     pdf_translate($pdf, 0, $y);
     pdf_scale($pdf, 1, -1);
     // Reflect across horizontal axis
     pdf_set_value($pdf, "horizscaling", -100);
     // Mirror
 }
Exemple #5
0
pdf_set_info($pdf, "Author", "Jesús M. Castagnetto");
pdf_set_info($pdf, "Title", "Ejemplo de Factura");
pdf_set_info($pdf, "Creator", "Jesú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');
pdf_set_font($pdf, "Helvetica", 10, winansi);
pdf_show_xy($pdf, 'Cliente Sin Salvacion S.A.', 20, $y - 100);
pdf_continue_text($pdf, '1 Calle Pequena');
pdf_continue_text($pdf, 'Cuidad Perdida, Puno 123');
pdf_set_font($pdf, "Helvetica", 10, winansi);
pdf_show_xy($pdf, 'Terminos: Pago Completo 15 horas', 150, $y - 100);
pdf_continue_text($pdf, 'Apt. Postal:  12345');
pdf_set_font($pdf, "Helvetica-Bold", 30, winansi);
pdf_show_xy($pdf, "* F A C T U R A *", $x - 250, $y - 112);
pdf_setcolor($pdf, 'fill', 'gray', 0.9, 0, 0, 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);
     }
 }