title: Image transparency in PDF using iTextSharp
body: <p>I have an incoming jpg file, that I can set a colour to transparent. When I add the image to another image, this works perfectly.</p>
  
  <p>I am trying to add the same image to a PDF using iTextSharp, but I cannot get the transparency to work.</p>
  
  <p>I have tried two ways, but neither is working. The first way was to open the image in a Bitmap, set transparency, then use that Bitmap object in the PDF. The second way (shown here) was saving the Bitmap to disk and opening the file into the iTextSharp image.</p>
  
  <pre><code>                    using (Bitmap b = new Bitmap(Image.FromFile(System.Web.HttpContext.Current.Server.MapPath("~/IncomingData/" + ImageFileName))))
                      {
                          b.MakeTransparent(Color.White);
                          b.Save(System.Web.HttpContext.Current.Server.MapPath("~/IncomingData/" + GuidFileName), System.Drawing.Imaging.ImageFormat.Png);
                          ImageFileName = GuidFileName;
  
                          iTextSharp.text.Image savedImage = iTextSharp.text.Image.GetInstance(Image.FromFile(System.Web.HttpContext.Current.Server.MapPath("~/IncomingData/" + GuidFileName)), iTextSharp.text.Color.WHITE);
  
                          savedImage.SetAbsolutePosition(Convert.ToSingle(x + 1.0), Convert.ToSingle(imageY + 12) - Convert.ToSingle(h));
                          savedImage.ScaleToFit(Convert.ToSingle(w), Convert.ToSingle(h));
                          contentByte.AddImage(savedImage, true);
                      }
  </code></pre>
  
  <p>I have seen that there is a Transparency option...</p>
  
  <pre><code>savedImage.Transparency = ???
  </code></pre>
  
  <p>but I don't know what to put in the values. I can't find anything on my searches.</p>