Access Keys:
Skip to content (Access Key - 0)

I googled for a maven2 plugin which uses Apache FOP for converting xml files into pdf files.

Since my search was not successful I made my own plugin.

Quick start:

  1. Download the source:
    $ svn co http://subversion.banapple.de/public/maven-fop-plugin
    
  2. Install the plugin:
    $ cd maven-fop-plugin 
    $ mvn install
    
  3. Get some xml file and an xsl file which transforms your xml to fo. I suppose these files are now somewhere in your maven project.
  4. Configure your project to use the fop plugin:
      <plugins>
        ...
        <plugin>
          <groupId>de.banapple.mojo</groupId>
          <artifactId>maven-fop-plugin</artifactId>
          <version>1.0-SNAPSHOT</version>
          <configuration>
            <inputFiles>
              <basedir>src/main/xml</basedir>
            </inputFiles>
            <xslFile>src/main/xsl-fo/foobar.xsl</xslFile>
          </configuration>
        </plugin>
        ...
      </plugins>
      
  5. Start maven: $ mvn de.banapple.mojo:maven-fop-plugin:1.0-SNAPSHOT:fop

You should now have some pdf files in the target folder.

The plugin is simple. I followed the plugin development guide. Not documented in the development guide is the usage of the DirectoryScanner with which filesets can be defined as parameters. The rest of the code is mostly taken from the Apache FOP documentation.

The plugin has minimal functionality and only allows to convert to pdf. Apache FOP allows a lot of other configuration which may be added in future versions of this plugin.

The plugin is deployed in the repository at url http://maven-repository.banapple.de.

For an example transformation have a look at the test class http://subversion.banapple.de/public/maven-fop-plugin/src/test/java/de/banapple/mojo/FopMojoTest.java.

del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks

Adaptavist Theme Builder (3.3.5-conf210) Powered by Atlassian Confluence 3.0.2, the Enterprise Wiki.