Using HTMLWorker and dynamically providing images is a bit
cumbersome. Dynamic images are important when reducing maximum memory
uses, and having a catalog of available images for the user to select.
Currently, you need to do something similar to:
class MyImageProvider extends HashMap {
Object get(Object key) {
... key will be a 'src' atribute, create appropriate itext Image on
the fly and return it, or return null
}
}
HashMap iprops = new HashMap();
iprops.put("img_static",new MyImprovider());
HTMLWorker worker = new HTMLWorker();
worker.setInterfaceProperties(iprops);
It would be better on line 195 instead of
HashMap images = (HashMap)interfaceProps.get
("img_static");
it was
Map images = (Map)interfaceProps.get("img_static");
that way the developer does not need to override HashMap. This change
is backwards compatible. In general you should NEVER use concrete
classes when the interface suffices.
Better yet, if you added an additional interface:
interface ImageProvider {
/**
* get the image for a SRC attribute or return null
*/
Image getImage(String src);
}
and added the code
ImageProvider provider = (ImageProvider)
interfaceProps.get("img_provider");
img = provider.getImage(src);
it would be much cleaner.
This change is also backwards compatible.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/