C# 中的 JPG 到 PDF 转换器
I would like to convert from an image (like jpg or png) to PDF.
I've checked out ImageMagickNET, but it is far too complex for my needs.
What other .NET solutions or code are there for converting an image to a PDF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
使用 iTextSharp 即可轻松完成:
Easy with iTextSharp:
iTextSharp 做得非常干净并且是开源的。此外,它还有作者的一本非常好的配套书,如果您最终做更有趣的事情,比如管理表单。对于正常使用,邮件列表和新闻组上有大量资源,提供如何执行常见操作的示例。
编辑:正如 @Chirag 的评论中提到的,@Darin 的答案 包含肯定可以与当前版本编译的代码。
用法示例:iTextSharp does it pretty cleanly and is open source. Also, it has a very good accompanying book by the author which I recommend if you end up doing more interesting things like managing forms. For normal usage, there are plenty resources on mailing lists and newsgroups for samples of how to do common things.
EDIT: as alluded to in @Chirag's comment, @Darin's answer has code that definitely compiles with current versions.
Example usage:另一个工作代码,尝试一下
Another working code, try it
我们非常幸运地使用了 PDFSharp(我们每天使用它进行 TIFF 和文本到 PDF 的转换,以处理数百个医疗索赔)。
http://pdfsharp.com/PDFsharp/
One we've had great luck with is PDFSharp (we use it for TIFF and Text to PDF conversion for hundreds of medical claims every day).
http://pdfsharp.com/PDFsharp/
借助 Docotic.Pdf 库 可以轻松完成此类任务。
下面是一个从给定图像(实际上不仅仅是 JPG)创建 PDF 的示例:
免责声明:我为该库的供应商工作。
Such task can be easily done with help of Docotic.Pdf library.
Here is a sample that creates PDF from given images (not only JPGs, actually):
Disclaimer: I work for the vendor of the library.
如果你想以跨平台的方式做到这一点,而不需要任何三十部分库,
或支付任何许可证,您可以使用此代码。
它需要一系列图片(我认为它只适用于 jpg)及其大小并返回一个 pdf 文件,每页一张图片。
您必须创建两个文件:
文件图片:
文件 PDF 导出:
您可以通过这种简单的方式使用代码
////////////////////////////// ///////////导出PDF////////////////////////////////////// /
If you want to do it in a cross-platform way, without any thirty part library,
or paying any license, you can use this code.
It takes an array of pictures (I think it only works only with jpg) with its sizes and return a pdf file, with one picture per page.
You have to create two files:
File Picture:
File PDFExport:
You can use the code in this easy way
///////////////////////////////////////Export PDF//////////////////////////////////////
您需要安装 Acrobat。在 Acrobat DC 上测试。这是 VB.net 代码。由于这些对象是 COM 对象,因此您应该执行“释放对象”,而不仅仅是“=Nothing”。您可以在此处转换此代码:https://converter.telerik.com/
You need Acrobat to be installed. Tested on Acrobat DC. This is a VB.net code. Due to that these objects are COM objects, you shall do a 'release object', not just a '=Nothing". You can convert this code here: https://converter.telerik.com/
不确定您是否正在寻找免费/开源解决方案或也考虑商业解决方案。但如果您要包含商业解决方案,可以使用名为 EasyPDF SDK 的工具包,它提供了用于将图像(以及许多其他文件类型)转换为 PDF 的 API。它支持 C#,可以在这里找到:
C# 代码如下所示:
为了完全透明,我应该否认我为 EasyPDF SDK 的制作者工作(因此是我的处理方式),所以这个建议不无一些个人偏见:) 但如果您有兴趣,请随时查看评估版本。干杯!
not sure if you're looking for just free / open source solutions or considering commercial ones as well. But if you're including commercial solutions, there's a toolkit called EasyPDF SDK that offers an API for converting images (plus a number of other file types) to PDF. It supports C# and can be found here:
The C# code would look as follows:
To be fully transparent, I should disclaim that I do work for the makers of EasyPDF SDK (hence my handle), so this suggestion is not without some personal bias :) But feel free to check out the eval version if you're interested. Cheers!
我使用Sautinsoft,它非常简单:
I use Sautinsoft, its very simple:
您可以尝试使用此代码示例将任何图像转换为 PDF:
或者如果您需要将图像类转换为 PDF:
You may try to convert any Images to PDF using this code sample:
Or if you need to convert Image Class to PDF:
有很多差异工具。我使用的一个是 PrimoPDF(免费)http://www.primopdf.com/ 你可以打印文件并将其以 pdf 格式打印到您的驱动器上。适用于 Windows
Many diff tools out there. One I use is PrimoPDF (FREE) http://www.primopdf.com/ you go to print the file and you print it to pdf format onto your drive. works on Windows