pdf - 将 Maven 站点软件文档转换为 PDF

标签 pdf maven-2 maven-plugin maven-pdf-plugin

我目前正在开发一个用 Java 编写的项目,我正在使用 Maven 和 maven-site-plugin 生成一个包含所有相关 JavaDoc、报告等的网站。我同时需要能够转换相同的将文档转换为可读的、类似于书籍的格式。是否有任何脚本或工具可以用来获取网站,并将其转换为格式合理的 PDF 或其他样式,以便可以轻松地以数字形式提供或打印出来?

最佳答案

maven-pdf-plugin生成项目文档的 PDF。
需要考虑的文档中的两个注释:

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.


您实际上可以在 POM 中指定聚合属性(请参见下面的示例)。
此配置将在 docs 的每个构建上生成 PDF。 profile 处于事件状态(您可以在每次构建时都这样做,但对于您的典型开发周期来说会有点慢:
<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</aggregate>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </profile>
</profiles>
您可以使用 -P docs 在命令行上激活配置文件或使用 activation如果你想要更细粒度的配置。

关于pdf - 将 Maven 站点软件文档转换为 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1492881/

相关文章:

pdf - 如何使用 PyPDF2 提取目录?

maven-2 - 通过 Maven 使用调试信息编译 Scala 类

java - 通过 shell 添加对现有 pom.xml 的依赖

gradle - 如何将属性部分添加到 gradle 生成的 pom 文件中?

ruby - 将 PDF 转换为 JPG 时质量低下

angularjs - 使用 angularjs 在浏览器的新窗口中打开 PDF

maven-2 - 无效的jar文件实际上是html的Maven问题

java - Maven : Java classes don't compile after Ant task

maven - 仅在父级中运行 Maven 插件

ios - UIActivityViewController - 保留从 URL 读取的附加文件的文件名