Maven PDF Plugin
Maven PDF Plugin
Maven PDF Plugin
......................................................................................................................................
The Apache Software Foundation 2017-12-22
Table of Contents i
Table of Contents
.......................................................................................................................................
Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2. Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Filtering Document Descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4. Configuring Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5. Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6. FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1 Introduction
.......................................................................................................................................
1.1.2 Usage
General instructions on how to use the PDF Plugin can be found on the usage page. Some more
specific use cases are described in the examples given below.
In case you still have questions regarding the plugin's usage, please have a look at the FAQ and
feel free to contact the user mailing list. The posts to the mailing list are archived and could already
contain the answer to your question as part of an older thread. Hence, it is also worth browsing/
searching the mail archive.
If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug
report in our issue tracker. When creating a new issue, please provide a comprehensive description of
your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem.
For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue
are very much appreciated. Of course, patches are welcome, too. Contributors can check out the
project from our source repository and will find supplementary information in the guide to helping
with Maven.
1.1.3 Examples
Have a look at the PDF version of this web site.
The following examples show how to use the PDF Plugin in more advanced usecases:
2 Usage
.......................................................................................................................................
where the first pdf refers to the plugin's alias, and the second pdf refers to a plugin goal.
By default, the pdf will be generated in target/pdf/ directory.
Notes:
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.
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.
Note: In this case, the pdf plugin is coupled with the Maven Site plugin to generate both site
documentation and pdfs into the default output site directory, i.e. target/site. You just need to call
mvn site.
<meta>
<title>Maven PDF Plugin</title>
<author>The Apache Maven Project</author>
</meta>
<cover>
<coverTitle>${project.name}</coverTitle>
<coverSubTitle>v. ${project.version}</coverSubTitle>
<coverType>User Guide</coverType>
<projectName>${project.name}</projectName>
<projectLogo>http://maven.apache.org/images/maventxt_logo_200.gif</projectLogo>
<companyName>The Apache Software Foundation</companyName>
<companyLogo>http://www.apache.org/images/asf_logo_wide.png</companyLogo>
</cover>
</document>
The meta information is only used for the pdf cover page if no cover element is given. The toc
generates a Table of Contents and specifies the order of files to include in the pdf. For a complete
description of the file format, see the Document Model Reference.
Notes:
1. Only a few of document metadatas are used by the Fo/iText sinks like author, confidential, date
and title.
2. The document descriptor supports filtering as described in the filtering example.
2.1.4 Internationalization
The PDF plugin is able to generate internationalized pdfs, similar to the site creation.
To enable multiple locales, add a configuration similar to the following to your POM:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<version>1.4</version>
<configuration>
<locales>en,fr</locales>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
This will generate two pdfs, one English and one French. Like the site plugin, if en is your current
locale, then it will be generated at the root of the site, with a copy of the French translation of the site
in the fr/ subdirectory.
The following is a complete internationalized directory layout for site and pdf plugins:
+- src/
+- site/
+- apt/
| +- index.apt (Default version)
|
+- fr/
| +- apt/
| +- index.apt (French version)
|
+- site.xml (Default site descriptor)
+- site_fr.xml (French site descriptor)
+- pdf.xml (Default pdf descriptor)
+- pdf_fr.xml (French pdf descriptor)
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
</xsl:stylesheet>
3.2 Example
For instance, if you have defined the following pom.xml and pdf.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<version>1.0-SNAPSHOT</version>
<name>Your project</name>
...
<developers>
<developer>
<email>[email protected]</email>
...
</developer>
</developers>
...
</project>
<document xmlns="http://maven.apache.org/DOCUMENT/1.0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DOCUMENT/1.0.1 http://maven.apache.org/xsd/document-1.0.1.x
outputName="maven-pdf-plugin-doc-${project.version}">
<meta>
<title>User guide of ${project.name} version ${project.version}</title>
<author>${project.developers[0].email}</author>
</meta>
<cover>
<coverdate>${date}</coverdate> <!-- current date in ISO 8601 format -->
<!-- <coverdate>${day}/${month}/${year}</coverdate> current date in French format -->
...
</cover>
</document>
The title will be User guide of Your project version 1.0-SNAPSHOT and the author will
be [email protected].
4 Configuring Reports
.......................................................................................................................................
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1.2</version>
<reportSets>
<reportSet>
<reports>
<report>project-team</report>
...
</reports>
</reportSet>
</reportSets>
</plugin>
...
</plugins>
</reporting>
...
<project>
Notes:
1. to exclude the reporting generation inside the PDF, you should add -
DincludeReports=false in the command line.
2. only internal reporting plugins will be added in the PDF, external reporting plugins like Javadoc
will be skipped.
4.1.1 Enhancements
Having many reports increases hugely the build time, so it is recommended to select only the wanted
reports to be included in the PDF. It is recommended to define a reporting profile in your pom,
similar to the following:
<project>
...
<profiles>
<profile>
<id>pdf</id>
<reporting>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1.2</version>
<reportSets>
<reportSet>
<reports>
<report>cim</report>
<!-- take too long time
<report>dependencies</report> -->
<report>dependency-convergence</report>
<report>dependency-management</report>
<!-- already present
<report>index</report> -->
<report>issue-tracking</report>
<report>license</report>
<report>mailing-list</report>
<report>plugin-management</report>
<report>plugins</report>
<report>project-team</report>
<report>scm</report>
<report>summary</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<build>
<defaultGoal>pdf:pdf</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<version>1.4</version>
</plugin>
</plugins>
</build>
</profile>
...
</profiles>
...
<project>
changelog:dev-activity
changelog:file-activity
4. maven-changes-plugin
changes:jira-report
changes:trac-report
4. maven-checkstyle-plugin
Note: could take a lot of time.
4. maven-dependency-plugin
4. maven-plugin-plugin
4. maven-pmd-plugin
pmd:pmd
4. maven-project-info-reports-plugin
Note: dependencies report could take a lot of time.
project-info-reports:dependencies
project-info-reports:dependency-
convergence
project-info-reports:dependency-
management
project-info-reports:index
project-info-reports:issue-tracking
project-info-reports:license
project-info-reports:mailing-list
project-info-reports:plugin-
management
project-info-reports:plugins
project-info-reports:project-team
project-info-reports:scm
project-info-reports:summary
4. maven-surefire-report-plugin
4. cobertura-maven-plugin
4. l10n-maven-plugin
Snapshot (1.0-alpha-3-
Reports Release (1.0-alpha-2) SNAPSHOT)
l10n:report
4. javancss-maven-plugin
5 Limitations
.......................................................................................................................................
• Menu sub-items are not supported in TOC (every source document starts a new chapter).
6 FAQ
.......................................................................................................................................
6.2 General
Is it possible to create a book?
The Doxia Book code currently only supports the iText module for generating a pdf book.
[top]
If you want your image centered you may put it explicitly inside a centered paragraph:
<p align="center">
<img src="image.jpg"/>
</p>
or you may use the Doxia-specific class attribute in a surrounding <div> block:
<div class="figure">
<img src="image.jpg"/>
</div>
[top]