1 51 package org.apache.fop.pdf; 52 53 import java.io.UnsupportedEncodingException ; 55 import java.util.ArrayList ; 56 57 64 public class PDFPages extends PDFObject { 65 66 69 protected ArrayList kids = new ArrayList (); 70 71 74 protected int count = 0; 75 76 78 88 public PDFPages(int number) { 89 super(number); 90 } 91 92 97 public void addPage(PDFPage page) { 98 this.kids.add(page.referencePDF()); 99 page.setParent(this); 100 this.incrementCount(); 101 } 102 103 108 public int getCount() { 109 return this.count; 110 } 111 112 115 public void incrementCount() { 116 this.count++; 117 } 119 120 125 public byte[] toPDF() { 126 StringBuffer p = new StringBuffer (this.number + " " + this.generation 127 + " obj\n<< /Type /Pages\n/Count " 128 + this.getCount() + "\n/Kids ["); 129 for (int i = 0; i < kids.size(); i++) { 130 p = p.append(kids.get(i) + " "); 131 } 132 p = p.append("] >>\nendobj\n"); 133 134 try { 135 return p.toString().getBytes(PDFDocument.ENCODING); 136 } catch (UnsupportedEncodingException ue) { 137 return p.toString().getBytes(); 138 } 139 } 140 141 } 142 | Popular Tags |