diff options
author | Keiron Liddle <keiron@apache.org> | 2001-11-12 13:10:12 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2001-11-12 13:10:12 +0000 |
commit | 364a97a6e14a63a4df36b64d492a26ea59cfa173 (patch) | |
tree | 942ed7e3c5f0d0b43a0c6856ea6b548ce130a7fc /src/org/apache/fop/pdf | |
parent | 290c33e88a2fbc430d52e3754813e6519193982c (diff) | |
download | xmlgraphics-fop-364a97a6e14a63a4df36b64d492a26ea59cfa173.tar.gz xmlgraphics-fop-364a97a6e14a63a4df36b64d492a26ea59cfa173.zip |
some changes for out of order rendering and rendering to a renderer
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194565 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/pdf')
-rw-r--r-- | src/org/apache/fop/pdf/PDFDocument.java | 41 | ||||
-rw-r--r-- | src/org/apache/fop/pdf/PDFInfo.java | 56 | ||||
-rw-r--r-- | src/org/apache/fop/pdf/PDFPage.java | 31 | ||||
-rw-r--r-- | src/org/apache/fop/pdf/PDFXObject.java | 18 |
4 files changed, 90 insertions, 56 deletions
diff --git a/src/org/apache/fop/pdf/PDFDocument.java b/src/org/apache/fop/pdf/PDFDocument.java index d24a2129b..06bf33b54 100644 --- a/src/org/apache/fop/pdf/PDFDocument.java +++ b/src/org/apache/fop/pdf/PDFDocument.java @@ -21,15 +21,13 @@ import org.apache.fop.render.pdf.CIDFont; import org.apache.fop.render.pdf.fonts.LazyFont; import org.apache.fop.datatypes.IDReferences; -import org.apache.fop.layout.Page; import org.apache.fop.layout.FontMetric; import org.apache.fop.layout.FontDescriptor; // Java import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Enumeration; +import java.util.HashMap; import java.awt.Rectangle; /** @@ -147,7 +145,7 @@ public class PDFDocument { * the XObjects Map. * Should be modified (works only for image subtype) */ - protected Hashtable xObjectsMap = new Hashtable(); + protected HashMap xObjectsMap = new HashMap(); /** * the objects themselves @@ -936,48 +934,27 @@ public class PDFDocument { * * @return the created /Page object */ - public PDFPage makePage(PDFResources resources, PDFStream contents, + public PDFPage makePage(PDFResources resources, int pagewidth, int pageheight) { /* * create a PDFPage with the next object number, the given * resources, contents and dimensions */ - PDFPage page = new PDFPage(++this.objectcount, resources, contents, + PDFPage page = new PDFPage(++this.objectcount, resources, pagewidth, pageheight); - if(pendingLinks != null) { - for(int count = 0; count < pendingLinks.size(); count++) { - PendingLink pl = (PendingLink)pendingLinks.get(count); - PDFGoTo gt = new PDFGoTo(++this.objectcount, - page.referencePDF()); - gt.setDestination(pl.dest); - addTrailerObject(gt); - PDFInternalLink internalLink = - new PDFInternalLink(gt.referencePDF()); - pl.link.setAction(internalLink); - } - pendingLinks = null; - } -/* - if (currentPage != null) { - Enumeration enum = currentPage.getIDList().elements(); - while (enum.hasMoreElements()) { - String id = enum.nextElement().toString(); - idReferences.setInternalGoToPageReference(id, - page.referencePDF()); - } - } -*/ /* add it to the list of objects */ this.objects.add(page); - /* add the page to the Root */ - this.root.addPage(page); - return page; } + public void addPage(PDFPage page) { + /* add it to the list of objects */ + this.objects.add(page); + } + /** * make a link object * diff --git a/src/org/apache/fop/pdf/PDFInfo.java b/src/org/apache/fop/pdf/PDFInfo.java index a8215fcea..bbef7a897 100644 --- a/src/org/apache/fop/pdf/PDFInfo.java +++ b/src/org/apache/fop/pdf/PDFInfo.java @@ -7,9 +7,8 @@ package org.apache.fop.pdf; -// Java -import java.io.IOException; -import java.io.PrintWriter; +import java.util.Date; +import java.text.SimpleDateFormat; /** * class representing an /Info object @@ -21,6 +20,15 @@ public class PDFInfo extends PDFObject { */ protected String producer; + protected String title = null; + protected String author = null; + protected String subject = null; + protected String keywords = null; + + // the name of the application that created the + // original document before converting to PDF + protected String creator; + /** * create an Info object * @@ -39,6 +47,22 @@ public class PDFInfo extends PDFObject { this.producer = producer; } + public void setTitle(String t) { + this.title = t; + } + + public void setAuthor(String a) { + this.author = a; + } + + public void setSubject(String s) { + this.subject = s; + } + + public void setKeywords(String k) { + this.keywords = k; + } + /** * produce the PDF representation of the object * @@ -46,9 +70,29 @@ public class PDFInfo extends PDFObject { */ public byte[] toPDF() { String p = this.number + " " + this.generation - + " obj\n<< /Type /Info\n/Producer (" + this.producer - + ") >>\nendobj\n"; + + " obj\n<< /Type /Info\n"; + if(title != null) { + p += "/Title (" + this.title + ")\n"; + } + if(author != null) { + p += "/Author (" + this.author + ")\n"; + } + if(subject != null) { + p += "/Subject (" + this.subject + ")\n"; + } + if(keywords != null) { + p += "/Keywords (" + this.keywords + ")\n"; + } + + p += "/Producer (" + this.producer + ")\n"; + + // creation date in form (D:YYYYMMDDHHmmSSOHH'mm') + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss"); + String str = sdf.format(date) + "+00'00'"; + p += "/CreationDate (D:" + str + ")"; + p += " >>\nendobj\n"; return p.getBytes(); } - } + diff --git a/src/org/apache/fop/pdf/PDFPage.java b/src/org/apache/fop/pdf/PDFPage.java index 8fce26098..320a0def7 100644 --- a/src/org/apache/fop/pdf/PDFPage.java +++ b/src/org/apache/fop/pdf/PDFPage.java @@ -78,6 +78,37 @@ public class PDFPage extends PDFObject { } /** + * create a /Page object + * + * @param number the object's number + * @param resources the /Resources object + * @param pagewidth the page's width in points + * @param pageheight the page's height in points + */ + public PDFPage(int number, PDFResources resources, + int pagewidth, int pageheight) { + + /* generic creation of object */ + super(number); + + /* set fields using parameters */ + this.resources = resources; + this.pagewidth = pagewidth; + this.pageheight = pageheight; + + this.annotList = null; + } + + /** + * set this page contents + * + * @param contents the contents of the page + */ + public void setContents(PDFStream contents) { + this.contents = contents; + } + + /** * set this page's parent * * @param parent the /Pages object that is this page's parent diff --git a/src/org/apache/fop/pdf/PDFXObject.java b/src/org/apache/fop/pdf/PDFXObject.java index 8d670a574..cefff8a08 100644 --- a/src/org/apache/fop/pdf/PDFXObject.java +++ b/src/org/apache/fop/pdf/PDFXObject.java @@ -119,24 +119,6 @@ public class PDFXObject extends PDFObject { } byte[] toPDF() { - /* - * Not used any more - * String p = this.number + " " + this.generation + " obj\n"; - * p = p + "<</Type /XObject\n"; - * p = p + "/Subtype /Image\n"; - * p = p + "/Name /Im"+Xnum+"\n"; - * p = p + "/Width "+fopimage.getpixelwidth()+"\n"; - * p = p + "/Height "+fopimage.getpixelheight()+"\n"; - * p = p + "/BitsPerComponent 8\n"; - * if (fopimage.getcolor()) - * p = p + "/ColorSpace /DeviceRGB\n"; - * else - * p = p + "/ColorSpace /DeviceGray\n"; - * p = p + "/Filter /ASCIIHexDecode\n"; - * p = p + "/Length "; - * return p; - */ return null; } - } |