10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.12 Ruby BindingInstalling the PDFlib Ruby Edition. The Ruby 1 extension mechanism works by loadinga shared library at runtime. For the PDFlib binding to work, the Ruby interpreter musthave access to the PDFlib extension library for Ruby. This library (on Windows/Linux/Unix: PDFlib.so; on Mac OS X: PDFlib.bundle) will usually be installed in the site_rubybranch of the local ruby installation directory, i.e. in a directory with a name similar tothe following:/usr/local/lib/ruby/site_ruby//However, Ruby will search other directories for extensions as well. In order to retrieve alist of these directories you can use the following ruby call:ruby -e "puts $:"This list will usually include the current directory, so for testing purposes you can simplyplace the PDFlib extension library and the scripts in the same directory.Error Handling in Ruby. The Ruby binding installs a special error handler which translatesPDFlib exceptions to native Ruby exceptions. The Ruby exceptions can be dealtwith by the usual rescue technique:begin...some PDFlib instructions...rescue PDFlibException => peprint "PDFlib exception occurred in hello sample:\n"print "[" + pe.get_errnum.to_s + "] " + pe.get_apiname + ": " + pe.get_errmsg + "\n"Ruby on Rails. Ruby on Rails 2 is an open-source framework which facilitates Web developmentwith Ruby. The PDFlib extension for Ruby can be used with Ruby on Rails;examples are included in the package. Follow these steps to run the PDFlib examples forRuby on Rails:> Install Ruby.> Install Ruby on Rails.> Unpack the PDFlib package for Ruby which contains samples for Ruby on Rails.> Change to the bind/ruby/RubyOnRails directory and start the Ruby web server:ruby script/server> Point your browser to http://localhost:3000.The code for the PDFlib samples can be found in app/controllers/pdflib_controller.rb.Local PDFlib installation. If you want to use PDFlib only with Ruby on Rails, but cannotinstall it globally for general use with Ruby, you can install PDFlib locally in the vendorsdirectory within the Rails tree. This is particularly useful if you do not have permissionto install Ruby extensions for general use, but want to work with PDFlib in Rails nevertheless.1. See www.ruby-lang.org/en2. See www.rubyonrails.org2.12 Ruby Binding 43

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!