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 / tcl / image.tcl < prev    next >
Encoding:
Text File  |  2001-07-04  |  1.1 KB  |  47 lines  |  [TEXT/WIsH]

  1. #!/bin/sh
  2. # $Id: image.tcl,v 1.10 2001/03/15 13:42:54 rjs Exp $
  3. #
  4. # PDFlib client: image example in Tcl
  5. #
  6.  
  7. # Hide the exec to Tcl but not to the shell by appending a backslash\
  8. exec tclsh "$0" ${1+"$@"}
  9.  
  10. # The lappend line is unnecessary if PDFlib has been installed
  11. # in the Tcl package directory
  12. set auto_path [linsert $auto_path 0 .libs .]
  13.  
  14. package require pdflib 4.0
  15.  
  16. set p [PDF_new]
  17.  
  18. if {[PDF_open_file $p "image.pdf"] == -1} {
  19.     puts stderr "Couldn't open PDF file!"
  20.     exit
  21. }
  22.  
  23. PDF_set_info $p "Creator" "image.tcl"
  24. PDF_set_info $p "Author" "Thomas Merz"
  25. PDF_set_info $p "Title" "image sample (Tcl)"
  26.  
  27. set image [PDF_open_image_file $p "jpeg" "../../test/nesrin.jpg" "" 0]
  28.  
  29. if {$image == -1} {
  30.     puts stderr "Couldn't open image file!"
  31.     exit
  32. }
  33.  
  34. # See the PDFlib manual for more advanced image size calculations
  35. set width [PDF_get_value $p "imagewidth" image]
  36. set height [PDF_get_value $p "imageheight" image]
  37.  
  38. # We generate a page with the image's dimensions
  39. PDF_begin_page $p $width $height
  40. PDF_place_image $p $image 0 0 1
  41. PDF_close_image $p $image
  42. PDF_end_page $p
  43.  
  44. PDF_close $p
  45.  
  46. PDF_delete $p
  47.