diff options
author | eschaeffer <eschaeffer@unknown> | 2000-05-23 09:23:53 +0000 |
---|---|---|
committer | eschaeffer <eschaeffer@unknown> | 2000-05-23 09:23:53 +0000 |
commit | db0063f4d8c568ddc05c4d8c6151a742a6afb217 (patch) | |
tree | a33d58d63d88aae64eaea3c329ab707864594bb1 /src/org | |
parent | ae6b3d8f63207bdeea32bf9179081a4e2e599ad9 (diff) | |
download | xmlgraphics-fop-db0063f4d8c568ddc05c4d8c6151a742a6afb217.tar.gz xmlgraphics-fop-db0063f4d8c568ddc05c4d8c6151a742a6afb217.zip |
modify this class to only create a new PDFXobject if needed
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193374 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/apache/fop/pdf/PDFDocument.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/org/apache/fop/pdf/PDFDocument.java b/src/org/apache/fop/pdf/PDFDocument.java index a32342950..ee0b39c53 100644 --- a/src/org/apache/fop/pdf/PDFDocument.java +++ b/src/org/apache/fop/pdf/PDFDocument.java @@ -63,6 +63,7 @@ import org.apache.fop.datatypes.ColorSpace; import java.io.IOException; import java.io.PrintWriter; import java.util.Vector; +import java.util.Hashtable; import java.awt.Rectangle; /** @@ -123,6 +124,10 @@ public class PDFDocument { /** 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 */ @@ -729,10 +734,16 @@ public class PDFDocument { } 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; } |