1 51 package org.apache.fop.pdf; 52 53 import java.io.UnsupportedEncodingException ; 54 55 69 public class PDFPage extends PDFObject { 70 71 74 protected String parent; 75 76 79 protected PDFResources resources; 80 81 84 protected PDFStream contents; 85 86 89 protected int pagewidth; 90 91 94 protected int pageheight; 95 96 99 protected PDFAnnotList annotList; 100 101 110 public PDFPage(int number, PDFResources resources, PDFStream contents, 111 int pagewidth, int pageheight) { 112 113 114 super(number); 115 116 117 this.resources = resources; 118 this.contents = contents; 119 this.pagewidth = pagewidth; 120 this.pageheight = pageheight; 121 122 this.annotList = null; 123 } 124 125 130 public void setParent(PDFPages parent) { 131 this.parent = parent.referencePDF(); 132 } 133 134 139 public void setAnnotList(PDFAnnotList annotList) { 140 this.annotList = annotList; 141 } 142 143 148 public PDFAnnotList getAnnotList() { 149 return this.annotList; 150 } 151 152 public void addShading(PDFShading shading) { 153 this.resources.addShading(shading); 154 } 155 156 161 public byte[] toPDF() { 162 StringBuffer sb = new StringBuffer (); 163 164 sb = sb.append(this.number + " " + this.generation + " obj\n" 165 + "<< /Type /Page\n" + "/Parent " 166 + this.parent + "\n" 167 + "/MediaBox [ 0 0 " + this.pagewidth + " " 168 + this.pageheight + " ]\n" + "/Resources " 169 + this.resources.referencePDF() + "\n" + "/Contents " 170 + this.contents.referencePDF() + "\n"); 171 if (this.annotList != null) { 172 sb = sb.append("/Annots " + this.annotList.referencePDF() + "\n"); 173 } 174 175 sb = sb.append(">>\nendobj\n"); 176 177 try { 178 return sb.toString().getBytes(PDFDocument.ENCODING); 179 } catch (UnsupportedEncodingException ue) { 180 return sb.toString().getBytes(); 181 } 182 } 183 184 } 185 | Popular Tags |