Exemple #1
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, "");
     }
 }
Exemple #2
0
}
pdf_setcolor($pdf, 'fill', 'gray', 0, 0, 0, 0);
pdf_setcolor($pdf, 'stroke', 'gray', 0, 0, 0, 0);
pdf_moveto($pdf, 20, $y - 160);
pdf_lineto($pdf, $x - 20, $y - 160);
pdf_stroke($pdf);
pdf_moveto($pdf, $x - 140, $y - 160);
pdf_lineto($pdf, $x - 140, 80);
pdf_stroke($pdf);
pdf_set_font($pdf, "Times-Bold", 18, winansi);
pdf_show_xy($pdf, "Articulo", 30, $y - 150);
pdf_show_xy($pdf, "Precio", $x - 100, $y - 150);
pdf_set_font($pdf, "Times-Italic", 15, winansi);
$offset = 177;
foreach ($items as $item) {
    pdf_show_xy($pdf, $item[0], 30, $y - $offset);
    pdf_show_boxed($pdf, '$' . number_format($item[1], 2), $x - 55, $y - $offset, 0, 0, 'right');
    $offset += 24;
    $total += $item[1];
}
pdf_set_font($pdf, "Times-Bold", 17, winansi);
$offset += 24;
pdf_show_xy($pdf, 'Total', 30, $y - $offset);
pdf_show_boxed($pdf, '$' . number_format($total, 2), $x - 55, $y - $offset, 0, 0, 'right');
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header("Content-disposition: inline; filename=invoice.pdf");
header("Content-length: " . strlen($data));
echo $data;