windows HTML2PDF 转换

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/431117/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:48:25  来源:igfitidea点击:

HTML2PDF Conversion

htmlwindowspdf

提问by

We're developing software for both Linux and Windows that requires CVS files to be generated into PDF reports. I've written a program in C to turn the CVS files into HTML files (td, tr etc.) and am then converting the HTML into PS using html2ps and then ps2pdf under Linux.

我们正在为 Linux 和 Windows 开发需要将 CVS 文件生成为 PDF 报告的软件。我用 C 编写了一个程序,将 CVS 文件转换为 HTML 文件(td、tr 等),然后在 Linux 下使用 html2ps 和 ps2pdf 将 HTML 转换为 PS。

However as mentioned above we're also developing for Windows and while I'm aware that html2ps and ps2pdf are available under Windows they have a few dependencies which are going to cause headaches for our clients (namely Perl and Ghostscript). Are there any native Windows console applications that will convert HTML into PDF that can be distributed as single executable files with no major dependencies?

然而,如上所述,我们也在为 Windows 开发,虽然我知道 html2ps 和 ps2pdf 在 Windows 下可用,但它们有一些依赖项,这会给我们的客户带来麻烦(即 Perl 和 Ghostscript)。是否有任何本机 Windows 控制台应用程序可以将 HTML 转换为 PDF,可以作为没有主要依赖项的单个可执行文件分发?

回答by Russell Leggett

I would like to add a new entry that I've used recently - wkhtmltopdf- it is an open source project that uses webkit to render, which means that it has all the latest and greatest available including CSS3, SVG, and can even let javascript run before creating the pdf. It doesn't have the same level of polish as princeXML, but its the best FOSS solution I've found.

我想添加一个我最近使用的新条目 - wkhtmltopdf- 它是一个使用 webkit 进行渲染的开源项目,这意味着它拥有所有最新最好的可用资源,包括 CSS3、SVG,甚至可以让 javascript在创建 pdf 之前运行。它没有与princeXML 相同的润色水平,但它是我发现的最好的FOSS 解决方案。

I haven't used it for multi-page documents yet, but I believe it does have support for css page-breaks.

我还没有将它用于多页文档,但我相信它确实支持 css 分页符。

回答by Russell Leggett

I've used Prince XMLwith Java and it is extremely powerful and easy to use, but it's also commercial.

我已经将Prince XML与 Java 一起使用,它非常强大且易于使用,但它也是商业化的。

回答by Nitin Bhide

Check Pisa. Its completely written in python so should work on Windows and Unix. The license is GPL but commercial license is also available.

检查比萨。它完全用 python 编写,所以应该可以在 Windows 和 Unix 上运行。许可证是 GPL,但也可以使用商业许可证。

回答by Hafthor

I've used ExpertPDF's Html2Pdfconverter component. Easy to make .NET app to convert.

我使用过 ExpertPDF 的Html2Pdf转换器组件。轻松制作 .NET 应用程序进行转换。

回答by Chas. Owens

I had lots of luck with HTMLDOC. It is open source and available on many platforms and has a commercial version if you want to pay for it.

我在HTMLDOC上很幸运。它是开源的,可在许多平台上使用,如果您想付费,它还有商业版本。

回答by TygerKrash

We've used Apache FOPin the past to convert XML docs to PDF. perhaps not quite what you are looking for but It might be an option?

我们过去曾使用Apache FOP将 XML 文档转换为 PDF。也许不是你正在寻找的,但它可能是一种选择?

回答by eagle779

As Russell says wkhtmltopdf is probably the best bet. I've created a free online service to convert HTML to PDF files http://www.html2pdfrocket.comwhich uses wkhtmltopdf but makes the process easy and cross platform.

正如罗素所说 wkhtmltopdf 可能是最好的选择。我创建了一个免费的在线服务来将 HTML 转换为 PDF 文件http://www.html2pdfrocket.com它使用 wkhtmltopdf 但使这个过程变得简单和跨平台。

I've added examples on how to conversion HTML to PDF for PHP, C#, RUBY and HTML. You could trigger it in JavaScript if you wish.

我已经添加了有关如何将 HTML 转换为 PHP、C#、RUBY 和 HTML 的 PDF 的示例。如果您愿意,您可以在 JavaScript 中触发它。

It's being used by the heart foundation and others to create PDF files in real time, for example PDFs of recipes, invoices, receipts etc - although you can download and cache the PDF output if you wish.

心脏基金会和其他人正在使用它来实时创建 PDF 文件,例如食谱、发票、收据等的 PDF - 尽管您可以根据需要下载和缓存 PDF 输出。

Hope you find it helpful and please write to me there if you have feedback or if you need help getting kwhtmltopdf working in your own env.

希望你觉得它有帮助,如果你有反馈或者如果你需要帮助让 kwhtmltopdf 在你自己的环境中工作,请写信给我。

回答by Anjisan

I've used Asposewhich has both .NET and Java libraries to use for PDF conversion. I think it's great to use, but there's definitely a cost involved.

我使用了Aspose,它具有 .NET 和 Java 库可用于 PDF 转换。我认为它很好用,但肯定会涉及成本。

Since you're looking for something open source, I might suggest iText. I hear it's good, but haven't used it myself.

由于您正在寻找开源的东西,我可能会建议iText。听说不错,不过自己没用过。

回答by Steve Claridge

PDFLibcould be bundled with a native application written by yourselves to create PDFs. It's a great library - used to be free but it looks you have to pay for it these days.

PDFLib可以与您自己编写的本机应用程序捆绑在一起以创建 PDF。这是一个很棒的图书馆 - 曾经是免费的,但现在看来您必须为此付费。

Another option, but it doesn't exactly fit your non-dependency requirement, is iTextSharp.

另一种选择是iTextSharp,但它并不完全符合您的非依赖性要求。