private static void HandleReplaceImage(object sender, PdfReplaceImageEventArgs e) { if (e.OldImageID.Value == "/Im1") { // Replace the existing image with a checkers board. MemoryStream checkers = new MemoryStream(new byte[] { 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0 }); PdfRawImage rawImage = new PdfRawImage(checkers); rawImage.Width = 5; rawImage.Height = 5; rawImage.BitsPerComponent = 8; rawImage.ColorSpace = new PdfGrayColorSpace(); e.NewImage = rawImage; } else { if (e.OldImageID.Value == "/Im2") { // Remove the image from the page by setting the new image (the replacement image) to null. e.NewImage = null; } } }