home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 February / PCWorld_2002-02_cd.bin / Software / Vyzkuste / pdflib / pdflib-4.0.1.sit / pdflib-4.0.1 / bind / php / image.php < prev    next >
Encoding:
PHP Script  |  2001-05-16  |  912 b   |  40 lines  |  [TEXT/LMAN]

  1. <?php
  2. # $id$
  3.  
  4. $p = PDF_new();
  5. PDF_open_file($p, "");
  6.  
  7. PDF_set_info($p, "Creator", "image.php");
  8. PDF_set_info($p, "Author", "Rainer Schaaf");
  9. PDF_set_info($p, "Title", "image sample (PHP)");
  10.  
  11. $imagefile = "nesrin.jpg";
  12.  
  13. $image = PDF_open_image_file($p, "jpeg", $imagefile, "", 0);
  14. if (!$image) {
  15.     die("Couldn't open image ".$imagefile);
  16. }
  17.  
  18. # See the PDFlib manual for more advanced image size calculations
  19. $width = PDF_get_value($p, "imagewidth", $image);
  20. $height = PDF_get_value($p, "imageheight", $image);
  21.  
  22. # We generate a page with the image's dimensions
  23. PDF_begin_page($p, $width, $height);
  24. PDF_place_image($p, $image, 0, 0, 1);
  25. PDF_close_image($p, $image);
  26. PDF_end_page($p);
  27.  
  28. PDF_close($p);
  29.  
  30. $buf = PDF_get_buffer($p);
  31. $len = strlen($buf);
  32.  
  33. header("Content-type: application/pdf");
  34. header("Content-Length: $len");
  35. header("Content-Disposition: inline; filename=image.pdf");
  36. print $buf;
  37.  
  38. PDF_delete($p);
  39. ?>
  40.