Skip to content

Simple webserver that exposes apache fop over HTTP (for instance for non JVM projects)

Notifications You must be signed in to change notification settings

palap/apache-fop-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apache FOP Server

Simple embedded HTTP server that provides creating PDF's using apache fop.

The server uses the Unfiltered Scala HTTP server toolkit and Jetty.

Testing is done using the Dispatch HTTP client library.

Must run with OpenJDK8

How to build

mvn assembly:assembly

How to use

Use the docker image:

docker run zilverline/fop:1.8

Or download one of the tar.gz from the downloads page

tar xvzf apache-fop-server-[version].tar.gz
java -cp apache-fop-server.jar:lib/* org.zilverline.fop.FopServer

This will start the server on port 9999. You can use the command line argument to increase the amount of posting data, optional. 400000 bytes restriction by default.

To generate a pdf one should POST to http://localhost:9999/pdf with 2 parameters: xml containing the XML representation of the pdf and xsl as the stylesheet to be used.

Example on how to use in Ruby using httpclient

require 'httpclient'

module Adapters::ApacheFopAdapter
  FOP_URL = "http://localhost"
  FOP_PORT = 9999

  def get_pdf(xml, xsl)
    body = {xsl: IO.read(xsl), xml: xml}
    client = HTTPClient.new
    result = client.post "#{FOP_URL}:#{FOP_PORT}/pdf", body
    result.body
  end

  module_function :get_pdf
end

An example upstart script for installing this on the server could be

# apache-fop-server - simple webserver to enable generation of pdfs
#
# Simple embedded Jetty server to enable generation of pdfs using apache-fop

description     "webserver to enable generation of pdfs using apache-fop"

start on runlevel [2345]
stop on runlevel [!2345]

expect fork

script
  chdir /opt/apps/apache-fop-server
  exec java -cp apache-fop-server.jar:lib/* org.zilverline.fop.FopServer
end script

Fork and patch to contribute!

About

Simple webserver that exposes apache fop over HTTP (for instance for non JVM projects)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • XSLT 45.4%
  • JavaScript 35.0%
  • HTML 14.7%
  • CSS 4.7%
  • Other 0.2%