Code Monkey home page Code Monkey logo

apache-fop-server's Introduction

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.

How to build

mvn assembly:assembly

How to use

Use the docker image:

docker run zilverline/fop:1.7

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.

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!

apache-fop-server's People

Contributors

lvonk avatar erikrozendaal avatar derekkraan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.