views:

145

answers:

1

I am currently working on a project written in Java and I am using Maven and the maven-site-plugin to generate a website containing all the relevant JavaDoc, reports, etc. I am needing at the same time to be able to convert the same documentation into a readable, book-like format. Are there any scripts or tools out there designed to take a website, and convert it into a reasonably formatted PDF or other style so that it can be easily given digitally or printed out?

Thanks in advance.

+3  A: 

The maven-pdf-plugin generates a PDF of the project documentation.

Two notes from the documentation to consider:

Note 1: By default, the PDF plugin generates a PDF document which aggregates all your site documents. If you want to generate each site document individually, you need to add -Daggregate=false in the command line.

Note 2: By default, the PDF plugin uses the FOP implementation. The plugin also supports the iText implementation, you just need to add -Dimplementation=itext in the command line.

You can actually specify the aggregate property in your POM (see example below)

This configuration will generate the PDF on each build that the docs profile is active (you could do it on every build, but it would be a bit slow for your typical development cycle:

<profiles>
  <profile>
    <id>docs</id>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-pdf-plugin</artifactId>
      <version>1.0</version>
      <executions>
        <execution>
          <id>pdf</id>
          <phase>site</phase>
          <goals>
            <goal>pdf</goal>
          </goals>
          <configuration>
            <outputDirectory>
              ${project.reporting.outputDirectory}
            </outputDirectory>
            <aggregate>false</Daggregate>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </profile>
</profiles>

You can activate the profile on the command line with -P docs or use an activation configuration if you want to be finer-grained.

Rich Seller
Only thing this plugin seems to be unable to do is include some of the more extensive maven generated reports, as you have to give it a list of every file to include, which would be a ton for things like JavaDoc and wouldn't work dynamically as code changes.
FModa3
@FModa3 yes it is not ideal, but a workaround for that is to use something like the groovy plugin to process the files to generate the xsl
Rich Seller