JPG格式为PDF转换器在C# [英] JPG to PDF Convertor in C#

查看:181
本文介绍了JPG格式为PDF转换器在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从图像转换(如JPG或PNG)为PDF。

I would like to convert from an image (like jpg or png) to PDF.

我已经签出 ImageMagickNET ,但它远远满足我的需求太复杂了。

I've checked out ImageMagickNET, but it is far too complex for my needs.

.NET解决方案或code是什么其他的还有用于将图像转换为PDF?

What other .NET solutions or code are there for converting an image to a PDF?

推荐答案

iTextSharp的做它pretty干净而且是开源的。此外,它拥有一个非常好的书所附的作者我建议如果你最终这样做更有趣的事情比如管理形式。对于正常使用,则对邮件列表和新闻组中如何做共同的东西样本丰富的资源。

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.

编辑:作为暗示在 @奇拉格的评论,的 @达林的回答有code那肯定与当前版本的编译。

as alluded to in @Chirag's comment, @Darin's answer has code that definitely compiles with current versions.

<击>实例:

public static void ImagesToPdf(string[] imagepaths, string pdfpath)
{
    using(var doc = new iTextSharp.text.Document())
    {
        iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream(pdfpath, FileMode.Create));
        doc.Open();
        foreach (var item in imagepaths)
        {
            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(item);
            doc.Add(image);
        }
    }
}

这篇关于JPG格式为PDF转换器在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆