As already said in a comment, the pdf format does not have any image fields. Some pdf designers allow to emulate them using e.g. a button plus some javascript. But as the field is merely emulated, there is no image value. This is indeed the case for your two documents.
To retrieve the image from the source form button, therefore, we cannot take the button value but instead have to extract the image from the button appearance. We do this using the itext parser namespace classes with a custom ImageRenderListener
render listener class collecting bitmap images.
To set the image to the target form button, furthermore, we also cannot simply set the button value but have to set the button appearance. We do this using the iText AcroFields
methods GetNewPushbuttonFromField
and ReplacePushbuttonField
.
The ImageRenderListener
render listener class
All this render listener does is collect bitmap images:
public class ImageRenderListener : IRenderListener
{
public List<System.Drawing.Image> Images = new List<System.Drawing.Image>();
public void BeginTextBlock()
{ }
public void EndTextBlock()
{ }
public void RenderText(TextRenderInfo renderInfo)
{ }
public void RenderImage(ImageRenderInfo renderInfo)
{
PdfImageObject imageObject = renderInfo.GetImage();
if (imageObject == null)
{
Console.WriteLine("Image {0} could not be read.", renderInfo.GetRef().Number);
}
else
{
Images.Add(imageObject.GetDrawingImage());
}
}
}
A Copy
method for the image
This method retrieves the first image from the source reader form element and adds it to the target stamper form element:
void Copy(PdfReader source, string sourceButton, PdfStamper target, string targetButton)
{
PdfStream xObject = (PdfStream) PdfReader.GetPdfObjectRelease(source.AcroFields.GetNormalAppearance(sourceButton));
PdfDictionary resources = xObject.GetAsDict(PdfName.RESOURCES);
ImageRenderListener strategy = new ImageRenderListener();
PdfContentStreamProcessor processor = new PdfContentStreamProcessor(strategy);
processor.ProcessContent(ContentByteUtils.GetContentBytesFromContentObject(xObject), resources);
System.Drawing.Image drawingImage = strategy.Images.First();
Image image = Image.GetInstance(drawingImage, drawingImage.RawFormat);
PushbuttonField button = target.AcroFields.GetNewPushbuttonFromField(targetButton);
button.Image = image;
target.AcroFields.ReplacePushbuttonField(targetButton, button.Field);
}
An example
I filled an image into the source document using Adobe Acrobat Reader

and saved this document as Customer Order Form-Willi.pdf
.
Then I applied the above copy method:
String source = @"Customer Order Form-Willi.pdf";
String dest = @"Production Sheet.pdf";
String target = @"Production Sheet-withImage.pdf";
using (PdfReader sourceReader = new PdfReader(source))
using (PdfReader destReader = new PdfReader(dest))
using (PdfStamper targetStamper = new PdfStamper(destReader, File.Create(target), (char)0, true))
{
Copy(sourceReader, "proofImage", targetStamper, "proofImage");
}
The result in Production Sheet-withImage.pdf
:

Some words of warning
The code above is very optimistic and contains no plausibility checks. For production you should definitively make it more defensive and check for null
values, empty lists, etc.