我们使用 xhtml 转 pdf 非常成功,但是出现了一个新的要求,即每页上都有标题和页数。我们正在使用 Flying Saucer 的新版本。
我在这里遵循示例: http://today.java.net/pub/a/today/2007/06/26/generate-pdfs-with-flying-saucer-and-itext.html#page-specific-features< /a>
...但这行不通。标题将位于第一页的左上角。
如果我使用 r7 版本,标题和页码工作正常,但没有渲染传入的 html,而在 r8 中,标题\页码被忽略,但 html 渲染完美。用于测试的 xHTML 是从上面的 url 复制的。
我知道我一定错过了一些非常简单的东西,如果有人有任何想法\评论,我将非常感激听到。
We use xhtml to pdf with good success, but a new requirement came up to have headers and page count on every page. We are using newset release of Flying Saucer.
I followed example here: http://today.java.net/pub/a/today/2007/06/26/generating-pdfs-with-flying-saucer-and-itext.html#page-specific-features
...but this would not work. The header would be top left on first page.
If I use the r7 version, headers and page numbering works perfectly, but none of the passed in html is rendered, whilst in r8 the headers\ page numbers are ignored, but the html is rendered perfectly. xHTML used for tests is copied from url above.
I know I must be missing something very simple, if anyone has any ideas\ comments, I would be very grateful to hear.
发布评论
评论(2)
我们使用相同的方法,一切都很完美,但是我决定不使用飞碟的内置页眉/页脚,而是使用
PdfStamper
在生成 PDF 后添加它们,它工作得很好,这是一个例子。你可以像这样构建你的压模:
希望你发现这有帮助。
We use the same method and everything works perfectly, I have however decided not to use flying-saucer's built in headers/footers and use a
PdfStamper
to add them after the PDF is generated, it works quite well, here is an example.you can build your stamper like this:
Hope you find this helpful.
我认为他们在 r8 中更改了此功能....请尝试使用此方法:
https://gist.github.com/ 626264
I think they changed this functionality in r8.... try this method instead:
https://gist.github.com/626264