告诉 Flying Saucer 或 BIRT 缩放 html 以适合单个 pdf 页面
我的应用程序生成 HTML 报告。用户希望报告适合单个 PDF 页面 - 无论您需要多大的缩放比例。
目前,他们在 Internet Explorer 8 中渲染页面,并在“打印预览”窗口中手动定义自定义缩放级别,然后将页面打印为 PDF。我需要自动执行此操作。如何实现这一目标?
这些报告实际上是由 BIRT 创建的,因此基于 BIRT 的解决方案也很好。使用 BIRT 缩放选项可缩放文档以适合高度,但不适合宽度(因为它首先呈现 HTML,然后应用缩放)。
现在我尝试使用 Flying Saucer 将 BIRT 生成的 HTML 转换为 PDF。
我见过与 abcPDF (.NET) 和 CF8(见下文)相关的类似问题,但我需要一个基于 Java 的解决方案,并且我无法在 Flying Saucer 或 BIRT 中使用相同的技术。
My application generates HTML reports. The users want the report to fit a single PDF page - doesn't matter how much zoom you need for it.
Currently they render the page in Internet Explorer 8, and manually define a custom zoom level at the Print Preview window, then they print the page to PDF. I need to perform this operation automatically. How to achieve this?
The reports are actually created by BIRT, so BIRT-based solution is fine, too. Using the BIRT zoom options scale the document to fit height, but it doesn't fit width (because it first renders the HTML then apply the zoom).
Now I'm trying to use Flying Saucer to convert to PDF the BIRT-generated HTML.
I've saw similar questions related to abcPDF (.NET) and CF8 (se below) but I need a Java-based solution, and I wasn't able to use the same techniques with Flying Saucer or BIRT.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们向 Flying Saucer 项目添加了一个补丁请求请求,以允许 "itextrenderer 适合页面宽度"< /a>.
提议的补丁的想法是,我们将使页面尽可能宽(以避免截断),然后您可以在打印时使用 PDF 阅读器来适应页面。
We have added a pull request to Flying Saucer project for a patch to allow "itextrenderer fitting to page width".
The idea of the proposed patch is that we will make the page as wide as necessary (to avoid truncation) and then you can use PDF reader to fit to page when printing.
这是我基于 Flying Saucer / iText 找到的解决方案:
That's the solution I found, based on Flying Saucer / iText:
首先,我没有使用过飞碟。
但是,也许其他人可能正在阅读您的问题并需要不同的解决方案。
如果您使用 Java BIRT 引擎并自行设置渲染选项,则可以应用:
[PAGE_OVERFLOW = FIT_TO_PAGE_SIZE]
First, I have not used Flying Saucer.
However, perhaps others may be reading your question and need a different solution.
If you are using the Java BIRT Engine and setting the render options yourself, you can apply:
[PAGE_OVERFLOW = FIT_TO_PAGE_SIZE]