From 7ebb86cda2d0f1418d9dab338cc369c168fdf9b4 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 27 Mar 2003 11:05:18 +0000 Subject: [PATCH] No object number in the constructor. Add a separate method for registering kids. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196168 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/pdf/PDFPages.java | 38 ++++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/java/org/apache/fop/pdf/PDFPages.java b/src/java/org/apache/fop/pdf/PDFPages.java index d5cf9f56c..a7f8b260f 100644 --- a/src/java/org/apache/fop/pdf/PDFPages.java +++ b/src/java/org/apache/fop/pdf/PDFPages.java @@ -79,14 +79,15 @@ public class PDFPages extends PDFObject { * create a /Pages object. NOTE: The PDFPages * object must be created before the PDF document is * generated, but it is not written to the stream immediately. - * It must aslo be allocated an object ID (so that the kids + * It must also be allocated an object ID (so that the kids * can refer to the parent) so that the XRef table needs to * be updated before this object is written. * - * @param number the object's number + * @param objnum the object's number */ - public PDFPages(int number) { - super(number); + public PDFPages(int objnum) { + super(); + setObjectNumber(objnum); } /** @@ -95,10 +96,17 @@ public class PDFPages extends PDFObject { * @param page the PDFPage to add. */ public void addPage(PDFPage page) { - this.kids.add(page.referencePDF()); page.setParent(this); this.incrementCount(); } + + /** + * Use this method to notify the PDFPages object that a child page + * @param page the child page + */ + public void notifyKidRegistered(PDFPage page) { + this.kids.add(page.referencePDF()); + } /** * get the count of /Page objects @@ -118,19 +126,19 @@ public class PDFPages extends PDFObject { } /** - * represent the object in PDF - * - * @return the PDF string + * @see org.apache.fop.pdf.PDFObject#toPDFString() */ - public byte[] toPDF() { - StringBuffer p = new StringBuffer(this.number + " " + this.generation - + " obj\n<< /Type /Pages\n/Count " - + this.getCount() + "\n/Kids ["); + public String toPDFString() { + StringBuffer sb = new StringBuffer(64); + sb.append(getObjectID()). + append("<< /Type /Pages\n/Count "). + append(this.getCount()). + append("\n/Kids ["); for (int i = 0; i < kids.size(); i++) { - p = p.append(kids.get(i) + " "); + sb.append(kids.get(i)).append(" "); } - p = p.append("] >>\nendobj\n"); - return p.toString().getBytes(); + sb.append("] >>\nendobj\n"); + return sb.toString(); } } -- 2.39.5