How to use a c# Image object in itextSharp

馋奶兔 提交于 2019-12-12 05:39:20

问题


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


回答1:


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);

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).



来源:https://stackoverflow.com/questions/30139984/how-to-use-a-c-sharp-image-object-in-itextsharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!