Software Architect
Asimov Technologies
J2EE, JEE, PHP
Asimov Technologies
J2EE, JEE, PHP
Frank D. Martínez’s Blog
Software & Fun
Welcome to my technical blog. Here you can find my opinions and proposals over many software development things, mainly on open source projects.
VelFop = Velocity + Fop
I have developed a simple dynamic FOP processor with Velocity. I used it to make dynamic pdf reports and i got very good results.
You can download it from here:
- The jar file only: velfop.jar
You need to download velocity, fop and its dependencies from Apache. - The source code: velfop.zip
A Netbeans 6 project, A Basic example, and All dependency jars.
This is only a glue of two good projects from Apache.
For documentation please go to Apache projects homes.
Example usage:
// Velocity initialization.
VelocityEngine ve = new VelocityEngine();
ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
ve.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH,
new File(".").getCanonicalPath());
ve.init();
// Load the context.
Context context = new VelocityContext();
context.put("messages", Arrays.asList(
new String[] {"Message one", "Message Two", "Message three"}));
// Init source template and target output.
Template t = ve.getTemplate("src/report1.velfop");
FileOutputStream out = new FileOutputStream(
new File("./src/report1.pdf").getCanonicalPath());
// Do the magic
VelFopProcessor vfp = new VelFopProcessor();
vfp.merge(t, context, "application/pdf", out);
2 Responses to “VelFop = Velocity + Fop”
Leave a Reply
This site contains personal opinions about many things and does not intend to be normative in any aspect.
Java, J2EE, J2SE, JEE, Are trademarks of Sun Microsystems Inc.

Hola Frank, como va todo…
Quisiera preguntarle si esta aplicacion VelFop, puede generar a partir de un HTML, un PDF?
Gracias
Hola Julian,
El formato de entrada debe ser un documento XSL-FO con scripting de velocity para el contenido dinámico. El resultado puede ser PDF u otro.
Ref: http://es.wikipedia.org/wiki/XSL_Formatting_Objects
Ref: http://xmlgraphics.apache.org/fop/