Get Image by name and replace


We're looking to use the PDFNet SDK to replace text and image content
in order to produce print ready artwork. I'm currently replacing the
text content by using the following code:

'Save the changes to a new print-quality PDF
Dim doc As PDFDoc = New PDFDoc(Server.MapPath("/Docs/test.pdf"))

Dim field As Field = doc.GetField("FirstnameTextField")
If Not field Is Nothing Then
End If


doc.Save(Server.MapPath("/Docs/test_updated.pdf"), 0)

Is it possible to get hold of an image in a similar way (e.g by name)
instead of looping through all the page objects as per the examples?

Having read all the posts regarding replacing images I've so far been
unable to create a complete block of code that first finds a specific
image and then replaces it with a new image from an images directory.
If you could provide any examples of how to acheive this it would be
most apprechiated.

Finally, as the PDFs we'll be working with are print quality they're
generally going to be quite large files, up to 100MB. Is there
anything I need to keep in mind when working with files this size in
order to ensure optimal performance?


In case of text it seems that you are using AcroForms and you can use
a similar approach for images.

PDF forms fields are associated with widget annotations. A widget
annotation can be associated with a custom appearance that can be an
image, text, or any type of PDF content.

Assuming that your PDF form has a 'button' field and you want to
change the appearance of this field you can create a custom form
appearance (based on the new image) and use it with
annot.SetAppearance(form). For details please see the following

You can also use PDFNet API to replace images that are referenced
directly within PDF page content stream (using
image_b.GetSDFObj().GetObjNum())) but given that you are using
AcroForms to fill-in a template, the above approach may be a better