Home Page Creating PDF files with XSL-FO and Ruby
Home
XSL-FO Server
Getting started
Versions
How to
XSL-FO Editor
XSL-FO resources
XSL-FO in REALbasic
XSL-FO in Php
XSL-FO in VB 6
XSL-FO in .NET
XSL-FO in Ruby
XSL-FO in Delphi
Usage with APEX
XSL-FO in Ruby

The following script shows how you can call the FOP server from a Ruby program:

require 'net/http'

# connection data to server
http = Net::HTTP.new('localhost', 8087)
# URL and XSL-FO file name
path = '/J4LFOPServer/servlet?TEMPLATE=departmentEmployees.fo'
headers = {'Content-Type' => 'text/xml'}

# input xml data
xml="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> <departments><department><departmentName>R&amp;D</departmentName> <person> <name>John Schmidt</name> "
xml=xml +"<address>Red street 3</address> <status>A</status> </person> <person> <name>Paul Bones</name> <address>White street 5</address> <status>A</status> "
xml=xml +"</person> <person> <name>Mark Mayer</name> <address>Blue street 5</address> <status>A</status> </person> <person> <name>Janet Black</name> "
xml=xml +"<address>Black street 8</address> <status>I</status> </person></department><department> <departmentName>Sales</departmentName> <person> "
xml=xml +"<name>Juan Gomez</name> <address>Green street 3</address> <status>A</status> </person> <person> <name>Juliet Bones</name> <address>White street 5</address> "
xml=xml +" <status>A</status> </person></department></departments>"

# call xsl-fo server now
resp,pdfdata = http.post(path, xml, headers)

if (resp.code == '200')
    # save pdf data
    pdffile = File.new("output.pdf", 'wb')
    pdffile.puts pdfdata
    pdffile.close
end