We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replacing Images in Aspose.PDF using .NET

I’m using the following code in order to replace an image to a digital signature on a .pdf file.
Dim pdf As Document = New Document(_currentDocument.FullURL)
Dim userSig As UserSignatureEntity = New UserSignatureEntity(lueUserSignatures.EditValue)
Dim imgSig As Bitmap = userSig.Signature

Using imageStream As MemoryStream = New MemoryStream()
imgSig.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim xImages As XImageCollection = pdf.Pages(_currentDocumentSignature.PageIndex).Resources.Images
xImages.Replace(_currentDocumentSignature.SigIndex, imageStream, 100)

However, when I execute this, It replaces all images in the document with current signature.sig.PNG (31.4 KB)


Would you please share the sample source PDF document with us. We will test the scenario in our environment and address it accordingly.

Note: This pdf is converted from a word template.
I got it working if there is only 1 image on the 2nd page. I looped through the images and renamed them
For Each im As XImage In xImages
im.Name = _currentDocumentSignature.PageIndex.ToString() + “Sig” + n.ToString()
n = n + 1
But if all the images are on the same page, it does not work. The issue for me is:
“Dim xImages As XImageCollection = pdf.Pages(_currentDocumentSignature.PageIndex).Resources.Images” is only pulling one image instead all 6 that are on page 2. Thank you for the help.

TestDoc.pdf (73.4 KB)


We are checking it and will get back to you shortly.


We were able to reproduce the issue in our environment while using Aspose.PDF for .NET 20.8 and logged it as PDFNET-48704 in our issue tracking system. We will further look into its details and keep you informed about its rectification status. Please be patient and spare us some time.

We are sorry for the inconvenience.

Ok…Thank you. Please keep me posted.

Any update on this Issue? Thanks


The issue has recently been logged in our issue tracking system and is pending for review. It will be investigated/resolved on first come first serve basis. We will inform you as soon as we have some definite updates regarding its resolution. Please be patient and give us some time.

We apologize for the inconvenience.