在 C# 中在运行时创建 pdf 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/465433/
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
Creating pdf files at runtime in c#
提问by Lonzo
Is there a pdf library attached/that can be attached to .NET 3.5 that allows creation of pdf files at runtime i.e opening a new pdf file, writing to it line by line, embedding images, etc and closing the pdf file all in C# code?
是否有一个 pdf 库附加/可以附加到 .NET 3.5,它允许在运行时创建 pdf 文件,即打开一个新的 pdf 文件,逐行写入,嵌入图像等,并在 C# 代码中关闭 pdf 文件?
What I want is a set of tools and specifications which allow me to implement a customised pdf writer in C# without using Reporting Services' pdf output option.
我想要的是一组工具和规范,它们允许我在 C# 中实现自定义的 pdf 编写器,而无需使用 Reporting Services 的 pdf 输出选项。
采纳答案by ine
iTextSharp http://itextsharp.sourceforge.net/
iTextSharp http://itextsharp.sourceforge.net/
Complex but comprehensive.
复杂但全面。
回答by Knobloch
I have used (iTextSharp) in the past with nice results.
我过去使用过 ( iTextSharp) 并取得了不错的效果。
回答by Przemek
I strongly recommend: iTextSharp
我强烈推荐:iTextSharp
回答by Francisco Canedo
How about iTextSharp?
iTextSharp怎么样?
iText is a PDF (among others) generation library that is also ported (and kept in sync) to C#.
iText 是一个 PDF(以及其他)生成库,它也被移植(并保持同步)到 C#。
回答by balexandre
Well, free and not-for-free, I use WebSuperGoo ABCpdf .NETcomponent, that I just love it!
好吧,免费和非免费,我使用WebSuperGoo ABCpdf .NET组件,我就是喜欢它!
not-for-freebecause you need to pay for it.
不是免费的,因为您需要为此付费。
for freebecause even if you have to pay, they have a trial version and you can request a free licenseif you do not mind that, in your site show "This site uses WebSuperGoo ABCpdf .NET component" with a link to their website.
免费,因为即使您必须付费,他们也有试用版,如果您不介意,您可以申请免费许可证,在您的站点中显示“此站点使用 WebSuperGoo ABCpdf .NET 组件”以及指向其网站的链接。
I did that and I got a free license (version 5 in that time) so, I can say that it works (even if the website is no longer online) - I still have and use the component ~:)
我这样做了,并且获得了免费许可证(当时是第 5 版),因此,我可以说它有效(即使该网站不再在线)-我仍然拥有并使用该组件~:)
A wonderful thing that I love with this is that you can do everything that you can thing off with this, create PDF forms and dynamically fill them and send to user by mail or have them to download it, create a pdf from scratch, convert HTML pages into PDF, etc etc etc, please read the documentation, it is a wonderful component.
我喜欢的一件美妙的事情是,你可以做任何你可以做的事情,创建 PDF 表单并动态填写它们并通过邮件发送给用户或让他们下载它,从头开始创建一个 pdf,转换 HTML页面转换为 PDF 等,请阅读文档,这是一个很棒的组件。
回答by Taner Gediko?lu
回答by MarlonRibunal
I have posted a sample of how to use iTextSharp in one of my blogs:
我在我的博客之一中发布了如何使用 iTextSharp 的示例:
回答by Simon P
For this i looked into running LaTeX apps to generate a pdf. Although this option is likely to be far more complicated and heavy duty than the ones listed here.
为此,我研究了运行 LaTeX 应用程序来生成 pdf。尽管此选项可能比此处列出的选项复杂和繁重。
回答by Khadaji
I have used Gnostice in the past and found them to be very good.
我过去使用过 Gnostice,发现它们非常好。
回答by darkphoenix
iTextSharp is no longer licensed under the MIT/LGPL license. Versions greater than 4.1.6 are licensed under the Affero GPL, meaning you can't even use it in a SaaS (Software as a Service) scenario without licensing your code under the GPL, or a GPL-compatible license.
iTextSharp 不再根据 MIT/LGPL 许可进行许可。大于 4.1.6 的版本是根据 Affero GPL 许可的,这意味着您甚至不能在 SaaS(软件即服务)场景中使用它,而无需根据 GPL 或 GPL 兼容许可许可您的代码。
Other opensource PDF implementations in native .NET include
本机 .NET 中的其他开源 PDF 实现包括
- PDF Clown(make sure you get the patches to the latest version)
- PDFSharp
- PDFJet open source edition(commercial version also available, and you will need the JDK installed to build this)
- PDF Clown(确保您获得最新版本的补丁)
- PDFSharp
- PDFJet 开源版(商业版也可用,你需要安装 JDK 来构建它)
There's also a couple of Java PDF libraries (like PDFBox) you can convert to .NET using IKVM.
还有一些 Java PDF 库(如 PDFBox),您可以使用 IKVM 将其转换为 .NET。