在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 04:29:37  来源:igfitidea点击:

Creating pdf files at runtime in c#

c#pdf

提问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

Have a look at PDFSharp

看看PDFSharp

It is open source and it is written in .NET, I use it myself for some PDF invoice generation.

它是开源的,是用 .NET 编写的,我自己使用它来生成一些 PDF 发票。

回答by MarlonRibunal

回答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,发现它们非常好。

http://www.gnostice.com/PDFOne_dot_Net.asp

http://www.gnostice.com/PDFOne_dot_Net.asp

回答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 实现包括

There's also a couple of Java PDF libraries (like PDFBox) you can convert to .NET using IKVM.

还有一些 Java PDF 库(如 PDFBox),您可以使用 IKVM 将其转换为 .NET。