1 51 package org.apache.fop.pdf; 52 53 import java.io.UnsupportedEncodingException ; 55 import org.apache.fop.datatypes.ColorSpace; 57 58 public class PDFICCStream extends PDFStream { 59 private int origLength; 60 private int len1, len3; 61 private byte[] originalData = null; 62 63 private ColorSpace cs; 64 65 public void setColorSpace(ColorSpace cs) throws java.io.IOException { 66 this.cs = cs; 67 setData(cs.getICCProfile()); 68 } 69 70 public PDFICCStream(int num) { 71 super(num); 72 cs = null; 73 } 74 75 public PDFICCStream(int num, ColorSpace cs) throws java.io.IOException { 76 super(num); 77 setColorSpace(cs); 78 } 79 80 protected int output(java.io.OutputStream stream) 83 throws java.io.IOException { 84 int length = 0; 85 String filterEntry = applyFilters(); 86 StringBuffer pb = new StringBuffer (); 87 pb.append(this.number).append(" ").append(this.generation).append(" obj\n<< "); 88 pb.append("/N ").append(cs.getNumComponents()).append(" "); 89 90 if (cs.getColorSpace() > 0) 91 pb.append("/Alternate /").append(cs.getColorSpacePDFString()).append(" "); 92 93 pb.append("/Length ").append((_data.size() + 1)).append(" ").append(filterEntry); 94 pb.append(" >>\n"); 95 byte[] p; 96 try { 97 p = pb.toString().getBytes(PDFDocument.ENCODING); 98 } catch (UnsupportedEncodingException ue) { 99 p = pb.toString().getBytes(); 100 } 101 stream.write(p); 102 length += p.length; 103 length += outputStreamData(stream); 104 try { 105 p = "endobj\n".getBytes(PDFDocument.ENCODING); 106 } catch (UnsupportedEncodingException ue) { 107 p = "endobj\n".getBytes(); 108 } 109 stream.write(p); 110 length += p.length; 111 return length; 112 } 113 114 115 } 116 | Popular Tags |