C# 基于 .NET 服务器的 PDF 生成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/450833/
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
.NET server based PDF generation
提问by J Evans
I'd like to dynamically generate content and then render to a PDF file. This processing would take place on a remote hosting server so using virtual printers etc is out. Does any have a recommendation for a .NET library (pref C#) that would work?
我想动态生成内容,然后呈现为 PDF 文件。此处理将在远程托管服务器上进行,因此无法使用虚拟打印机等。有没有关于 .NET 库(首选 C#)的建议?
I know that I could generate a bunch of PS code and package it myself but I'd prefer something a little less tricksy at this stage.
我知道我可以生成一堆 PS 代码并自己打包,但在这个阶段我更喜欢一些不那么棘手的东西。
Thanks!
谢谢!
回答by Stephen Wrighton
RDLC & the Report Viewer controls can generate PDF either at the Client's discretion or at server command which can then be served as a PDF mime-type.
RDLC 和报告查看器控件可以根据客户的判断或服务器命令生成 PDF,然后可以将其作为 PDF mime 类型提供。
回答by Akshay
Have a look at http://itextsharp.sourceforge.net/. Its open source.
Tutorial: http://itextdocs.lowagie.com/tutorial/
看看http://itextsharp.sourceforge.net/。它的开源。
教程:http: //itextdocs.lowagie.com/tutorial/
回答by Akshay
I've used PDF4NET from O2solutions with much success. They support all sorts of scenarios and digital signing of the pdf.
我已经成功地使用了 O2solutions 的 PDF4NET。他们支持各种场景和pdf的数字签名。
回答by marc_s
If your data is mostly in XML, you could also look at a XSL-FO solution - we're using Alt-Soft's Xml2Pdfwith great success. The "server" version is a bit of a misnomer - it's really just a single DLL you need to include in your Winforms, WPF or ASP.NET app - that's all!
如果您的数据主要是 XML,您还可以查看 XSL-FO 解决方案 - 我们使用Alt-Soft 的 Xml2Pdf取得了巨大成功。“服务器”版本有点用词不当——它实际上只是您需要包含在 Winforms、WPF 或 ASP.NET 应用程序中的单个 DLL——仅此而已!
Works like a charm (if you're familiar with XSLT and XSL-FO, or willing to learn it).
工作起来很有魅力(如果您熟悉 XSLT 和 XSL-FO,或者愿意学习它)。
Marc
马克
回答by Robert Gowland
We used a set of third party DLLs from PDFSharpwho in turn use DLLs from MigraDoc. I'm not privy to all the reasons that we went that direction (the decision was made by a senior developer), but I can tell you that:
我们使用了一组来自PDFSharp 的第三方 DLL,而后者又使用来自 MigraDoc 的 DLL。我不知道我们朝那个方向发展的所有原因(这个决定是由一位高级开发人员做出的),但我可以告诉你:
- It seems to be in active development.
- It had most of the features we needed.
- The source code is available. Although it used some patterns and conventions that I hadn't seen before, once I got on to them, it was fairly easy to make the changes. I added support for using the System.Drawing.Image directly rather than as saving files.
- It is not documented well either internally or externally.
- 它似乎正在积极发展。
- 它具有我们需要的大部分功能。
- 源代码可用。尽管它使用了一些我以前从未见过的模式和约定,但是一旦我掌握了它们,就可以很容易地进行更改。我添加了对直接使用 System.Drawing.Image 而不是保存文件的支持。
- 它在内部或外部都没有很好的记录。
回答by quimbo
I have had success using Siberix
我使用 Siberix 取得了成功
Corporate License: $350 USD (A single license covers unlimited number of company's developer seats, unlimited number of company's web servers and unlimited number of distributions as a part of your application.)
公司许可证:350 美元(单个许可证涵盖无限数量的公司开发人员席位、无限数量的公司 Web 服务器和无限数量的分发,作为您的应用程序的一部分。)
回答by rlb.usa
I've had good experiences with Winnovative's HTML to PDF.
我在Winnovative 的 HTML 转 PDF方面有很好的经验。
And bad ones with Open Source HTML Doc(Problems with form elements + CSS).
和 Open Source HTML Doc 的坏的(表单元素 + CSS 的问题)。
回答by wageoghe
We use the Amyuni PDF Converterand have used it successfully for several years. Our usage is via the COM interface, but it does support a .NET interface.
我们使用Amyuni PDF Converter,并且已经成功使用了好几年。我们的使用是通过 COM 接口,但它确实支持 .NET 接口。
回答by Vitaliy Fedorchenko
Free PDF Generator .NET(WkHtmlToPdf wrapper) can generate pretty PDF from HTML template with one line of code:
免费的PDF Generator .NET(WkHtmlToPdf 包装器)可以用一行代码从 HTML 模板生成漂亮的 PDF:
var pdfBytes = (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(htmlContent);
(all you need is one DLL, no external dependencies)
(您只需要一个 DLL,没有外部依赖项)