import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;
+import java.util.Hashtable;
import java.awt.Rectangle;
/**
/** the XObjects */
protected Vector xObjects = new Vector();
+ /** the XObjects Map.
+ Should be modified (works only for image subtype) */
+ protected Hashtable xObjectsMap = new Hashtable();
+
/**
* creates an empty PDF document
*/
}
public int addImage(FopImage img) {
- PDFXObject xObject = new PDFXObject(++this.objectcount,
+ // check if already created
+ String url = img.getURL();
+ PDFXObject xObject = (PDFXObject) this.xObjectsMap.get(url);
+ if (xObject != null) return xObject.getXNumber();
+ // else, create a new one
+ xObject = new PDFXObject(++this.objectcount,
++this.xObjectCount, img);
this.objects.addElement(xObject);
this.xObjects.addElement(xObject);
+ this.xObjectsMap.put(url, xObject);
return xObjectCount;
}