diff --git a/README.md b/README.md
index 463813d..d3bb163 100644
--- a/README.md
+++ b/README.md
@@ -6,15 +6,17 @@ The server uses the [Unfiltered](http://unfiltered.databinder.net/) Scala HTTP s
Testing is done using the [Dispatch](http://dispatch.databinder.net/) HTTP client library.
+### How to build
+
+ mvn assembly:assembly
+
### How to use
Download one of the tar.gz from the downloads page
- tar xvzf apache-server-fop-[version].tar.gz
- ./apache-fop-server start
-
-This will start the server in the background and will lsiten on port 9999. To stop the server you can use:
+ tar xvzf apache-fop-server-[version].tar.gz
+ java -cp apache-fop-server.jar:lib/* org.zilverline.fop.FopServer
- ./apache-fop-server stop
+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.
@@ -39,7 +41,7 @@ Example on how to use in Ruby using httpclient
An example upstart script for installing this on the server could be
- # apache-fop-server - simple webserver to enable generation of pdfs
+ # apache-fop-server - simple webserver to enable generation of pdfs
#
# Simple embedded Jetty server to enable generation of pdfs using apache-fop
@@ -48,11 +50,11 @@ An example upstart script for installing this on the server could be
start on runlevel [2345]
stop on runlevel [!2345]
- expect fork
+ expect fork
script
chdir /opt/apps/apache-fop-server
- exec sudo -u some-user ./apache-fop-server start
+ exec java -cp apache-fop-server.jar:lib/* org.zilverline.fop.FopServer
end script
-Fork and patch to contribute!
\ No newline at end of file
+Fork and patch to contribute!
diff --git a/src/main/resources/font/Calibri Bold Italic.ttf b/fop/font/Calibri Bold Italic.ttf
similarity index 100%
rename from src/main/resources/font/Calibri Bold Italic.ttf
rename to fop/font/Calibri Bold Italic.ttf
diff --git a/src/main/resources/font/Calibri Bold Italic.xml b/fop/font/Calibri Bold Italic.xml
similarity index 100%
rename from src/main/resources/font/Calibri Bold Italic.xml
rename to fop/font/Calibri Bold Italic.xml
diff --git a/src/main/resources/font/Calibri Bold.ttf b/fop/font/Calibri Bold.ttf
similarity index 100%
rename from src/main/resources/font/Calibri Bold.ttf
rename to fop/font/Calibri Bold.ttf
diff --git a/src/main/resources/font/Calibri Bold.xml b/fop/font/Calibri Bold.xml
similarity index 100%
rename from src/main/resources/font/Calibri Bold.xml
rename to fop/font/Calibri Bold.xml
diff --git a/src/main/resources/font/Calibri Italic.ttf b/fop/font/Calibri Italic.ttf
similarity index 100%
rename from src/main/resources/font/Calibri Italic.ttf
rename to fop/font/Calibri Italic.ttf
diff --git a/src/main/resources/font/Calibri Italic.xml b/fop/font/Calibri Italic.xml
similarity index 100%
rename from src/main/resources/font/Calibri Italic.xml
rename to fop/font/Calibri Italic.xml
diff --git a/src/main/resources/font/Calibri.ttf b/fop/font/Calibri.ttf
similarity index 100%
rename from src/main/resources/font/Calibri.ttf
rename to fop/font/Calibri.ttf
diff --git a/src/main/resources/font/Calibri.xml b/fop/font/Calibri.xml
similarity index 100%
rename from src/main/resources/font/Calibri.xml
rename to fop/font/Calibri.xml
diff --git a/fop/fop-config.xml b/fop/fop-config.xml
index 097c2ba..bfaba9d 100644
--- a/fop/fop-config.xml
+++ b/fop/fop-config.xml
@@ -1,24 +1,24 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
diff --git a/pom.xml b/pom.xml
index 2a82dbb..3c0a6b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,56 +8,17 @@
jar
Apache FOP Server: ${project.artifactId}
- 2.10.1
- 2.10
+ 2.11.7
+ 2.11
4.1.1
UTF-8
-
-
- zilverline-nexus
- zilverline-mirror
- http://nexus.zilverline.com/nexus/content/groups/public
-
- true
-
-
- false
-
-
-
-
-
- zilverline-nexus
- zilverline-mirror
- http://nexus.zilverline.com/nexus/content/groups/public
-
- true
-
-
- false
-
-
-
-
scm:git:git://github.com/zilverline/apache-fop-server.git
scm:git:git@github.com:zilverline/apache-fop-server.git
https://github.com/zilverline/apache-fop-server
HEAD
-
-
- zilverline-releases
- zilverline-releases
- http://nexus.zilverline.com/nexus/content/repositories/releases
-
-
- zilverline-releases
- zilverline-snapshots
- http://nexus.zilverline.com/nexus/content/repositories/snapshots
-
-
@@ -88,22 +49,22 @@
net.databinder
unfiltered_${scala.binary.version}
- 0.6.7
+ 0.8.4
net.databinder
unfiltered-filter_${scala.binary.version}
- 0.6.7
+ 0.8.4
net.databinder
unfiltered-jetty_${scala.binary.version}
- 0.6.7
+ 0.8.4
org.apache.xmlgraphics
fop
- 1.0
+ 2.1
commons-io
@@ -118,7 +79,7 @@
org.scalatest
scalatest_${scala.binary.version}
- 1.9.1
+ 2.1.3
test
@@ -130,7 +91,7 @@
net.databinder.dispatch
dispatch-core_${scala.binary.version}
- 0.9.5
+ 0.11.1
test
@@ -233,7 +194,7 @@
net.alchim31.maven
scala-maven-plugin
- 3.1.3
+ 3.2.2
@@ -271,8 +232,8 @@
maven-compiler-plugin
2.3.2
-
- 1.6
+
+ 1.8
@@ -312,6 +273,26 @@
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.5
+
+
+ false
+
+ font/Calibri Bold Italic.ttf
+ application/x-font
+ font/Calibri Bold.ttf
+ application/x-font
+ font/Calibri Italic.ttf
+ application/x-font
+ font/Calibri.ttf
+ application/x-font
+
+
+
+
diff --git a/src/main/scala/org/zilverline/fop/FopServer.scala b/src/main/scala/org/zilverline/fop/FopServer.scala
index be882b8..3de4301 100644
--- a/src/main/scala/org/zilverline/fop/FopServer.scala
+++ b/src/main/scala/org/zilverline/fop/FopServer.scala
@@ -20,7 +20,12 @@ object FopServer extends Logging {
}
def main(args: Array[String]): Unit = {
- System.setProperty("org.eclipse.jetty.server.Request.maxFormContentSize", "4000000")
+ val maxSize = args match {
+ case Array(max) => max
+ case Array() => "4000000"
+ }
+
+ System.setProperty("org.eclipse.jetty.server.Request.maxFormContentSize", maxSize)
unfiltered.jetty.Http.local(DefaultPort).filter(plan).run { server =>
sys.addShutdownHook(server.stop)
diff --git a/src/main/scala/org/zilverline/fop/PdfDocument.scala b/src/main/scala/org/zilverline/fop/PdfDocument.scala
index 233226e..884ac81 100644
--- a/src/main/scala/org/zilverline/fop/PdfDocument.scala
+++ b/src/main/scala/org/zilverline/fop/PdfDocument.scala
@@ -6,7 +6,7 @@ import javax.xml.transform.{Transformer, TransformerFactory, URIResolver}
import javax.xml.transform.sax.SAXResult
import javax.xml.transform.stream.StreamSource
import org.apache.commons.io.IOUtils
-import org.apache.fop.apps.{Fop, FopFactory}
+import org.apache.fop.apps.{FopConfParser, Fop, FopFactory}
import org.apache.xmlgraphics.util.MimeConstants
import uk.co.opsb.butler.ButlerIO
@@ -16,9 +16,10 @@ case class PdfDocument(xsl: String, xml: String, configFileName: String = "fop/f
val bos = new java.io.ByteArrayOutputStream()
try {
- info("Generating PDF")
+ val start = System.currentTimeMillis();
transform(createFop(bos))
- info("PDF generated!")
+ val time = System.currentTimeMillis() - start;
+ info(f"PDF generated in $time ms")
bos.toByteArray()
} finally {
IOUtils.closeQuietly(bos)
@@ -32,16 +33,9 @@ case class PdfDocument(xsl: String, xml: String, configFileName: String = "fop/f
}
private def createFopFactory(): FopFactory = {
- val fopFactory = FopFactory.newInstance()
-
- fopFactory.setURIResolver(new URIResolver {
- def resolve(href: String, base: String) = {
- new StreamSource(ButlerIO.inputStreamFrom(href))
- }
- })
-
- fopFactory.setUserConfig(new File(configFileName))
- fopFactory
+ val parser = new FopConfParser(new File(configFileName))
+ val builder = parser.getFopFactoryBuilder
+ builder.build();
}
private def transform(fop: Fop): Unit = {
diff --git a/src/test/scala/org/zilverline/fop/FopServerTest.scala b/src/test/scala/org/zilverline/fop/FopServerTest.scala
index d0791bc..50a0868 100644
--- a/src/test/scala/org/zilverline/fop/FopServerTest.scala
+++ b/src/test/scala/org/zilverline/fop/FopServerTest.scala
@@ -5,6 +5,7 @@ import java.io.File
import org.apache.commons.io.FileUtils
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.scalatest.matchers.ShouldMatchers
+import scala.concurrent.ExecutionContext.Implicits.global
/*
* Test the FopServer using the http://dispatch.databinder.net/ HTTP