We have an ASP.NET application that users use to generate certain reports. So far we had one PDF template that had one image on it, and we would just replace that image with our programatically generated one (graph).
We have used code from this site for that:http://blog.rubypdf.com/2007/12/12/how-to-replace-images-in-a-pdf/
Problem now is that we have two different images on one PDF page, and the code from link above selects both images on one page and replaces them all at once with our generated image.
Does anyone have any idea how to replace multiple different images on one page with itext?
Thanks
Ugh. First, let me rewrite some of that source.
Whew. the
getAsfunctions can save you quite a bit of knuckle-grease and make your code much clearer.Now. You need to be able to differentiate between the various images. If you’re willing to hard-code things, you could find out what the resource names are and go that route:
If you’re not willing to go with hardcoded resource names (and no one would fault you, quite the opposite, particularly when the order they appear (and thus the number on the end) depends on their order in a hash map… [shudder]), you may be able to differentiate based on image width and height.