问题
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