function image_rx_ry($image, $x, $y, $width, $height, $right, $bottom, $ox, $oy, $scale)
 {
     $tmpname = tempnam(WRITER_TEMPDIR, WRITER_FILE_PREFIX);
     imagepng($image->get_handle(), $tmpname);
     $pim = pdf_open_image_file($this->pdf, "png", $tmpname, "", 0);
     // Fill bottom-right quadrant
     $cy = $y;
     while ($cy + $height > $bottom) {
         $cx = $x;
         while ($cx < $right) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx += $width;
         }
         $cy -= $height;
     }
     // Fill bottom-left quadrant
     $cy = $y;
     while ($cy + $height > $bottom) {
         $cx = $x;
         while ($cx + $width > $x - $ox) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx -= $width;
         }
         $cy -= $height;
     }
     // Fill top-right quadrant
     $cy = $y;
     while ($cy < $y + $oy) {
         $cx = $x;
         while ($cx < $right) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx += $width;
         }
         $cy += $height;
     }
     // Fill top-left quadrant
     $cy = $y;
     while ($cy < $y + $oy) {
         $cx = $x;
         while ($cx + $width > $x - $ox) {
             pdf_place_image($this->pdf, $pim, $cx, $cy, $scale);
             $cx -= $width;
         }
         $cy += $height;
     }
     pdf_close_image($this->pdf, $pim);
     unlink($tmpname);
 }
Example #2
0
 function pdf_open_tiff($pdf, $fn)
 {
     return pdf_open_image_file($pdf, "tiff", $fn, null, null);
 }
Example #3
0
 /**
  * Adiciona uma imagem no documento PDF escalonando-a até a largura desejada.
  *
  * @param   string     $tipo      Tipo de imagem a ser incorporada
  * @param   string     $image     Caminho para o arquivo da imagem
  * @param   int|float  $x         Posição x (eixo horizontal)
  * @param   int|float  $y         Posição y (eixo vertical)
  * @param   int|float  $maxWidth  Largura máxima da imagem (usado para o cálculo de redução proporcional)
  */
 public function insertImageScaled($tipo, $image, $x, $y, $maxWidth)
 {
     $image = realpath($image);
     if (!is_readable($image)) {
         throw new Exception('Caminho para arquivo de imagem inválido: "' . $image . '"');
     }
     $y = $this->altura - $y;
     $im = pdf_open_image_file($this->pdf, $tipo, $image, '', 0);
     /**
      * Reduz em dois pixels. Algum bug da função da PDFLib necessita essa
      * compensação no cálculo para redução proporcional.
      */
     $maxWidth -= 2;
     $scale = 1;
     $width = PDF_get_value($this->pdf, 'imagewidth', $im);
     if ($width > $maxWidth) {
         $scale = $maxWidth / $width;
     }
     PDF_place_image($this->pdf, $im, $x, $y, $scale);
     PDF_close_image($this->pdf, $im);
 }
Example #4
0
 pdf_lineto($pdf, 132, 0);
 pdf_moveto($pdf, 122, 120);
 pdf_lineto($pdf, 132, 120);
 pdf_stroke($pdf);
 // Do we have album art?
 if ($node->getMainArt() != false) {
     $extension = substr(strrchr($node->getMainArt(), '.'), 1);
     $extension = strtolower($extension);
     if ($extension == 'jpg') {
         $pdfdfimage = pdf_open_image_file($pdf, 'jpeg', $node->getMainArt(), '', 0);
     }
     if ($extension == 'png') {
         $pdfdfimage = pdf_open_image_file($pdf, 'png', $node->getMainArt(), '', 0);
     }
     if ($extension == 'gif') {
         $pdfdfimage = pdf_open_image_file($pdf, 'gif', $node->getMainArt(), '', 0);
     }
     $sx = 121 / pdf_get_value($pdf, 'imagewidth', $pdfdfimage);
     $sy = 120 / pdf_get_value($pdf, 'imageheight', $pdfdfimage);
     pdf_scale($pdf, $sx, $sy);
     pdf_place_image($pdf, $pdfdfimage, 0, 0, 1);
 }
 //  +---------------------------------------------------------------------------+
 //  | Close PDF                                                                 |
 //  +---------------------------------------------------------------------------+
 pdf_end_page($pdf);
 pdf_close($pdf);
 $buffer = pdf_get_buffer($pdf);
 $file = $artist . ' - ' . $album . '.pdf';
 header('Content-Type: application/force-download');
 header('Content-Transfer-Encoding: binary');
Example #5
0
$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);
pdf_show_xy($pdf, "[Company Name]", $i_left + $i_offset, $i_top);
$i_top -= 30;
pdf_show_xy($pdf, "Address", $i_left, $i_top);
pdf_show_xy($pdf, "[Address]", $i_left + $i_offset, $i_top);
/*if ($str_city != "") {
Example #6
0
 $startx = 70;
 pdf_show_xy($pdf, 'This is to certify that:', $startx, 430);
 pdf_show_xy($pdf, strtoupper($name), $startx + 90, 391);
 $font = pdf_findfont($pdf, $fontname, 'host', 0);
 if ($font) {
     pdf_setfont($pdf, $font, 20);
 }
 pdf_show_xy($pdf, 'has demonstrated that they are certifiable ' . 'by passing a rigorous exam', $startx, 340);
 pdf_show_xy($pdf, 'consisting of three multiple choice questions.', $startx, 310);
 pdf_show_xy($pdf, "{$name} obtained a score of {$score}" . '%.', $startx, 260);
 pdf_show_xy($pdf, 'The test was set and overseen by the ', $startx, 210);
 pdf_show_xy($pdf, 'Fictional Institute of PHP Certification', $startx, 180);
 pdf_show_xy($pdf, "on {$date}.", $startx, 150);
 pdf_show_xy($pdf, 'Authorised by:', $startx, 100);
 // add bitmap signature image
 $signature = pdf_open_image_file($pdf, 'png', 'signature.png');
 pdf_place_image($pdf, $signature, 200, 75, 1);
 pdf_close_image($pdf, $signature);
 // set up colors for rosette
 pdf_setrgbcolor_fill($pdf, 0, 0, 0.4);
 //dark blue
 pdf_setrgbcolor_stroke($pdf, 0, 0, 0);
 // black
 // draw ribbon 1
 pdf_moveto($pdf, 630, 150);
 pdf_lineto($pdf, 610, 55);
 pdf_lineto($pdf, 632, 69);
 pdf_lineto($pdf, 646, 49);
 pdf_lineto($pdf, 666, 150);
 pdf_closepath($pdf);
 pdf_fill($pdf);