diff options
author | Dirk-Willem van Gulik <dirkx@apache.org> | 1999-11-08 19:12:49 +0000 |
---|---|---|
committer | Dirk-Willem van Gulik <dirkx@apache.org> | 1999-11-08 19:12:49 +0000 |
commit | 10070e8383ff94f3f256e346b8c4a2a493533cfb (patch) | |
tree | 59080d7faae7c0bd9ff4e5a48f4df4394d468a02 /src/org/apache/fop/pdf/PDFResources.java | |
parent | b510e7f15a798e944bb138993f2b586413adecbe (diff) | |
download | xmlgraphics-fop-10070e8383ff94f3f256e346b8c4a2a493533cfb.tar.gz xmlgraphics-fop-10070e8383ff94f3f256e346b8c4a2a493533cfb.zip |
Initial revision
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193213 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/pdf/PDFResources.java')
-rw-r--r-- | src/org/apache/fop/pdf/PDFResources.java | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/org/apache/fop/pdf/PDFResources.java b/src/org/apache/fop/pdf/PDFResources.java new file mode 100644 index 000000000..0bbb3aaff --- /dev/null +++ b/src/org/apache/fop/pdf/PDFResources.java @@ -0,0 +1,83 @@ +package org.apache.xml.fop.pdf; + +// Java +import java.io.PrintWriter; +import java.util.Enumeration; +import java.util.Vector; +import java.util.Hashtable; + +/** + * class representing a /Resources object. + * + * /Resources object contain a list of references to the fonts for the + * document + */ +public class PDFResources extends PDFObject { + + /** /Font objects keyed by their internal name */ + protected Hashtable fonts = new Hashtable(); + + protected Vector xObjects; + + /** + * create a /Resources object. + * + * @param number the object's number + */ + public PDFResources(int number) { + + /* generic creation of object */ + super(number); + } + + /** + * add font object to resources list. + * + * @param font the PDFFont to add + */ + public void addFont(PDFFont font) { + this.fonts.put(font.getName(),font); + } + + public void setXObjects(Vector xObjects) { + this.xObjects = xObjects; + } + + /** + * represent the object in PDF + * + * @return the PDF + */ + public String toPDF() { + StringBuffer p = new StringBuffer(this.number + " " + + this.generation + + " obj\n<< /Font << "); + + /* construct PDF dictionary of font object references */ + Enumeration fontEnumeration = fonts.keys(); + while (fontEnumeration.hasMoreElements()) { + String fontName = (String) fontEnumeration.nextElement(); + p = p.append("/" + fontName + " " + + ((PDFFont) fonts.get(fontName)).referencePDF() + + "\n"); + } + + p = p.append(">>\n/ProcSet [ /PDF /ImageC /Text ] "); + + if (!this.xObjects.isEmpty()) { + p = p.append("/XObject <<"); + for (int i = 1; i < this.xObjects.size(); i++) { + p = p.append("/Im" + i + " " + + ((PDFXObject) + this.xObjects.elementAt(i - + 1)).referencePDF() + + + " \n"); + } + } + + p = p.append(">>\nendobj\n"); + + return p.toString(); + } +} |