0

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

  • 1
    Welcome to Stack Overflow. Did you try _anything_ to solve your problem? Show your effort first so people might show theirs. Please read [FAQ] and [ask] as a start.. – Soner Gönül May 09 '15 at 12:35

1 Answers1

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

Chris Haas
  • 53,986
  • 12
  • 141
  • 274