如何在itextSharp中使用C#Image对象 [英] How to use a c# Image object in itextSharp

查看:696
本文介绍了如何在itextSharp中使用C#Image对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么解决方案可以将c#图像对象转换为iTextSharp兼容图像,以便在pdf中使用.

Is there any solution to convert a c# Image object to an iTextSharp compatible image to be used inside the pdf.

推荐答案

是.类iTextSharp.text.Image具有一个名为GetInstance()的方法,该方法具有18个重载,其中3个重载接受System.Drawing.Image.

Yes. The class iTextSharp.text.Image has a method called GetInstance() that has 18 overloads, 3 of which accept a System.Drawing.Image.

iTextSharp.text.Image.GetInstance(System.Drawing.Image, iTextSharp.text.BaseColor);

iTextSharp.text.Image.GetInstance(System.Drawing.Image, iTextSharp.text.BaseColor, Bool);

iTextSharp.text.Image.GetInstance(System.Drawing.Image, System.Drawing.Imaging.ImageFormat);

几乎在每种情况下,您都需要第一个参数,而只需将null传递给第二个参数(除非您希望将透明像素强制为某种颜色).

In almost every case you want the first one and you can just pass null for the second parameter (unless you want to force transparent pixels to be a certain color).

这篇关于如何在itextSharp中使用C#Image对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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