使用:
我使用以下方式生成了网站:
mvn site
然后我想从这个生成的站点生成PDF(根据PDF Plugin Usage,它使用站点文档)。我刚刚运行了命令:
mvn pdf:pdf
Maven确实会生成一个PDF,但它所做的只是显示项目名称,版本,“项目文档”和一个无处可去的TOC。缺少所有网站信息。
我是否需要在POM或其他内容中包含一些内容才能使其正常工作?我很感激帮助!
更新
根据下面的评论,我尝试使用pdf.xml
,这似乎让我更接近我正在寻找的输出。
pdf.xml 如下所示:
<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.xsd"
outputName="MyProject">
<meta>
<title>My Project</title>
<author>IT Department</author>
</meta>
<toc name="Table of Contents">
<item name="Introduction" ref="index.html"/>
<item name="Goals" ref="project-info.html"/>
<item name="Dependencies" ref="dependencies.html"/>
<item name="Dependency Tree" ref="dependency-tree.html"/>
<item name="Team" ref="team-list.html"/>
</toc>
<cover>
<coverTitle>${project.name}</coverTitle>
<coverSubTitle>v. ${project.version}</coverSubTitle>
<coverType>User Guide</coverType>
<projectName>${project.name}</projectName>
<projectLogo>http://somesite.com/logo.jpg</projectLogo>
<companyName>Google</companyName>
<companyLogo>http://google.com/logo.gif</companyLogo>
</cover>
</document>
我引用的HTML文件位于/src/site
。然后它们也被放入/target/pdf/site.tmp
文件夹。
Maven提供了以下输出,它有问题:
[INFO] --- maven-pdf-plugin:1.3:pdf (pdf) @ myproject---
[WARNING] Bookmarks: Unresolved id reference "./project-info" found.
[WARNING] Bookmarks: Unresolved id reference "./dependencies" found.
[WARNING] Bookmarks: Unresolved id reference "./dependency-tree" found.
[WARNING] Bookmarks: Unresolved id reference "./team-list" found.
[WARNING] Bookmarks: Unresolved id reference "./index" found.
[WARNING] Page i: Unresolved id reference "./project-info" found.
[WARNING] Page i: Unresolved id reference "./dependencies" found.
[WARNING] Page i: Unresolved id reference "./dependency-tree" found.
[WARNING] Page i: Unresolved id reference "./team-list" found.
[WARNING] Page i: Unresolved id reference "./index" found.
[WARNING] Bookmark with IDRef "./index" has a null PageViewport.
[WARNING] Bookmark with IDRef "./project-info" has a null PageViewport.
[WARNING] Bookmark with IDRef "./dependencies" has a null PageViewport.
[WARNING] Bookmark with IDRef "./dependency-tree" has a null PageViewport.
[WARNING] Bookmark with IDRef "./team-list" has a null PageViewport.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.354 s
[INFO] Finished at: 2015-03-20T10:03:37-04:00
[INFO] Final Memory: 30M/318M
[INFO] ------------------------------------------------------------------------
无论我尝试什么,我都无法解决未解析的ID引用问题。 PDF生成并显示TOC,但右侧没有数字,也没有显示其他页面。
答案 0 :(得分:4)
嗨我猜错误是由于maven-pdf插件默认不支持markdown。我有同样的问题,我可以通过在我的pom.xml中添加以下插件配置来修复它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>pdf</id>
<phase>site</phase>
<goals>
<goal>pdf</goal>
</goals>
<configuration>
<outputDirectory>${project.reporting.outputDirectory}</outputDirectory>
<includeReports>false</includeReports>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-markdown</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
</plugin>
答案 1 :(得分:1)
Maven PDF Plugin似乎需要文档描述符(请参阅usage page,段落文档描述符)。
默认情况下,它使用网站插件src/site/site.xml
(请参阅网站插件&#39; s http://maven.apache.org/plugins/maven-site-plugin/examples/sitedescriptor.html上的解释。
您可以选择使用src/site/pdf.xml
;它是专门针对PDF生成的文档描述符。
<强>更新强>
一个好的目录结构是:
+- src/
+- site/
+- apt/
| +- index.apt
| +- team.apt
|
+- xdoc/
| +- other.xml
|
+- site.xml
+- pdf.xml
在此示例中,您有三个源文档(index.apt,team.apt和other.xml),可以在网站(转换为html文件)或PDF中使用。