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 / perl / image.pl < prev    next >
Encoding:
Perl Script  |  2001-07-04  |  894 b   |  35 lines  |  [TEXT/McPL]

  1. #!/usr/bin/perl
  2. # $Id: image.pl,v 1.7.2.1 2001/05/16 12:25:50 york Exp $
  3. #
  4. # PDFlib client: image example in Perl
  5. #
  6.  
  7. use pdflib_pl 4.0;
  8.  
  9. $p = PDF_new();
  10.  
  11. die "Couldn't open PDF file" if (PDF_open_file($p, "image.pdf") == -1);
  12.  
  13. PDF_set_info($p, "Creator", "image.pl");
  14. PDF_set_info($p, "Author", "Thomas Merz");
  15. PDF_set_info($p, "Title", "image sample (Perl)");
  16.  
  17. $imagefile = "../../test/nesrin.jpg";
  18.  
  19. $image = PDF_open_image_file($p, "jpeg", $imagefile, "", 0);
  20. die "Couldn't open image '$imagefile'" if ($image == -1);
  21.  
  22. # See the PDFlib manual for more advanced image size calculations
  23. $width = PDF_get_value($p, "imagewidth", $image);
  24. $height = PDF_get_value($p, "imageheight", $image);
  25.  
  26. # We generate a page with the image's dimensions
  27. PDF_begin_page($p, $width, $height);
  28. PDF_place_image($p, $image, 0, 0, 1);
  29. PDF_close_image($p, $image);
  30. PDF_end_page($p);
  31.  
  32. PDF_close($p);
  33.  
  34. PDF_delete($p);
  35.