To use the PDFreactor Ruby API simply copy the PDFreactor.rb to a directory of your webserver where Ruby is enabled (by e.g. CGI or mod-ruby).
Then include the PDFreactor.rb with:
require 'PDFreactor.rb'
With just a few lines you can create and directly show PDFs inside your Ruby webapplication:
pdfreactor = PDFreactor.new()
pdfreactor.setAuthor("Myself")
pdfreactor.setAddLinks(true)
pdfreactor.setAddBookmarks(true)
result = pdfreactor.renderDocumentFromURL("http://www.realobjects.com")
if pdfreactor.getError() != nil
print "Content-type: text/html\n\n"
puts "Error during rendering: "+pdfreactor.getError()
else
print "Content-type: application/pdf\n\n"
print result
endTo directly output the PDF to the browser please use the following code before printing the result:
$stdout.binmode
PDFreactor methods in the Ruby API docs for all avaible options.