I would like to check the contents of a USB stick drive from a not-quite trusted source (my sister): is there a safe way to do this in OSX 10.9.5 or 10.10.1?


Question: Change Background Image in Itext to watermark or alter opacity c# ASP.net
Answer: Please take a look at the BackgroundTransparant example. It is a variation on the BackgroundImage example.

In your code, you're adding the Image to the Document instance. That's OK, but if you want to make such an image transparent, you need to introduce a soft mask. That's not difficult, but there's an easier way to make your background transparent: add the image to the direct content, and introduce a PdfGState defining the opacity:

PdfContentByte canvas = writer.getDirectContentUnder();
Image image = Image.getInstance(IMAGE);
image.SetAbsolutePosition(0, 0);
canvas.SaveState();
PdfGState state = new PdfGState();
state.setFillOpacity(0.6f);
canvas.setGState(state);
canvas.addImage(image);
canvas.restoreState();


Compare background_image.pdf with background_transparent.pdf to see the difference.

My example is written in Java, but it's very easy to port this to C#:

PdfContentByte canvas = writer.DirectContentUnder;
Image image = Image.GetInstance(IMAGE);
image.SetAbsolutePosition(0, 0);
canvas.SaveState();
PdfGState state = new PdfGState();
state.FillOpacity = 0.6f;
canvas.SetGState(state);
canvas.AddImage(image);
canvas.RestoreState();