java JSP/HTML 页面到 PDF 的转换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/790256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JSP/HTML Page to PDF conversion
提问by Gnaniyar Zubair
How to convert to PDF from my JSP/HTML file?.
如何从我的 JSP/HTML 文件转换为 PDF?。
I want to convert a particular part of my webpage to a PDF file. Is it possible?
我想将网页的特定部分转换为 PDF 文件。是否可以?
回答by Matthew Flaschen
Yes. Take a good look at booth Apache FOPand iText. No matter what you use, you'll probably have to do a little fiddling.
是的。好好看看Apache FOP和iText展位。无论您使用什么,您可能都需要做一些摆弄。
回答by yalestar
回答by jle
try wkhtmltopdf. It is a command line utility that can be provided an html file or web address and a save location for the pdf. Very easy to use and utilizes the same rendering engine as safari. Works MUCH better than many of the other parsers that I have used (that don't always support CSS and other advanced layout features.
试试wkhtmltopdf。它是一个命令行实用程序,可以提供 html 文件或网址以及 pdf 的保存位置。非常易于使用并使用与 safari 相同的渲染引擎。比我使用过的许多其他解析器(并不总是支持 CSS 和其他高级布局功能)要好得多。
回答by joschi
Take a look at html2ps (Perl)or html2ps (PHP). However, none of the two is implemented in Java.
看看html2ps (Perl)或html2ps (PHP)。但是,这两者都不是在 Java 中实现的。
You might also want to read this article.
您可能还想阅读这篇文章。
回答by coder hacker
flying saucer library is the best one to use. It works on top of itext and makes the task of conversion very easy.
飞碟库是最好用的。它在 itext 之上工作,使转换任务变得非常容易。

